Skip to content

bug(tests): takeover_manager.e2e_test.py default arg evaluated at import time #3747

@mrveiss

Description

@mrveiss

Problem

In autobot-backend/takeover_manager.e2e_test.py, TakeoverTestClient.__init__ uses:

def __init__(self, base_url: str = get_test_backend_url()):

Python evaluates default arguments at class definition time (module import), not at call time. If a test sets AUTOBOT_TEST_BACKEND_URL via monkeypatch.setenv after the module is imported, the default captures the stale value and the env var has no effect.

Fix

def __init__(self, base_url: str | None = None):
    self.base_url = base_url or get_test_backend_url()

Why

Tests that rely on monkeypatch.setenv to override the backend URL will silently use the wrong URL. Discovered during code review of PR #3727 (scored 100).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions