You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(tests): sys.modules stub pollution causes 34+ spurious unit test failures in full-suite runs #935
Running the full test suite causes 34+ unit tests to fail due to sys.modules stub pollution. All affected tests pass when run in isolation — they only fail when run after specific other test files in the same pytest session.
Root Cause
Several test files install module stubs into sys.modules without using a context manager or monkeypatch scope, so the stubs leak into subsequent test files. tests/unit/conftest.py has a _POP_PREFIXES list that cleans up known stubs between files, but it is missing entries for the modules that are actually being polluted.
Affected Tests (34+ failures, 28+ errors in full suite)
tests/conftest.py — add to _SYS_MODULES_INVARIANT_KEYS:
"services.docker_service",
These additions ensure the real modules are re-imported for each test file, eliminating cross-file contamination.
Acceptance Criteria
All 4 module names added to the appropriate conftest cleanup lists
pytest tests/unit/test_auto_retry_reader_race.py tests/unit/test_file_upload.py tests/unit/test_session_persistence_flag.py tests/unit/test_fleet_status_resilience.py tests/unit/test_startup_recovery_race.py tests/test_github_pat_propagation_unit.py passes in a single run (not just in isolation)
Activity
fix(#935): unit conftest stub cleanup for cross-file sys.modules poll…
vybe commentedon Jun 1, 2026
Shipped in v0.6.0 (released via #998).