Repository navigation
Description
Summary
50 tests in tests/test_audit_log_unit.py fail with ImportError at collection time when run as part of the full integration suite (pytest tests/). All 50 tests pass when run in isolation (pytest tests/test_audit_log_unit.py).
This is the largest single source of collection-error noise in the integration suite — 50 of the 65 collection errors observed on 2026-05-09 — and it masks signal for any other regression.
Context
Discovered via full test suite run on 2026-05-09:
26 failed, 1891 passed, 170 skipped, 300 warnings, 65 errors in 2508.21s (0:41:48)
Of those 65 errors, 50 are this file. Re-running in isolation:
pytest tests/test_audit_log_unit.py
# 50 passedThe file already stubs utils.helpers defensively at module top, then monkeypatches db.connection, db.audit, services.platform_audit_service, database, models per-test. The symptom suggests a different file, run earlier in the suite, leaves something in sys.modules (likely one of those modules) that breaks one of these imports at the next collection.
Reproduction
cd tests && source .venv/bin/activate
pytest --ignore=unit --ignore=process_engine --collect-only 2>&1 | grep "test_audit_log_unit"Acceptance Criteria
-
pytest tests/reports 0 collection errors againsttests/test_audit_log_unit.py. - All 50 tests still pass when the file runs (a) standalone, (b) in the full integration suite.
- Root-cause polluter identified in the PR description (which earlier file mutates
sys.modules).
Investigation hints
- Bisect by running
pytest tests/test_<earlier>.py tests/test_audit_log_unit.pyover alphabetically-earlier files until the breakage reproduces. - Likely candidates: any file collected before
test_audit_log_unit.pythat touchesservices.platform_audit_service,db.audit, ordatabase. - Workaround until root cause: extend the conftest defensive-snapshot pattern that fix(tests): green the unit-test suite (closes #660) #714 used for
tests/unit/test_file_upload.py(snapshot the realdb.*andservices.platform_audit_servicemodules before the polluter, restore on teardown).
Related
- Follows the same shape as fix(tests): update check_login_rate_limit import across 7 test files #752, fix(tests): add X-Internal-Secret header to internal API test fixtures #754 — atomic test-bed PR with no production code change.
- test: gate dev → open-PR merges on the unit-test suite #715 proposes a CI gate on the unit-test suite; resolving this clears integration-suite signal for the analogous integration gate.
Activity
fix(tests): conftest sys.modules baseline + tests-side lint (closes #762
fix(tests): drop bare sys.modules mutations in chat dispatched-marker…
fix(tests): drop bare sys.modules mutations in chat dispatched-marker…
fix(tests): drop bare sys.modules mutations in cleanup-orphan test
fix(tests): adopt sys.modules snapshot/restore in #606 chain test
docs(lint): mention named-helper escape hatch in sys.modules error me…
fix(tests): adopt sys.modules snapshot/restore in #783 cleanup test
fix(tests): restore unit-suite sys.modules between tests (#678)
fix(tests): adopt sys.modules snapshot/restore in #606 chain test
docs(lint): mention named-helper escape hatch in sys.modules error me…
fix(tests): adopt sys.modules snapshot/restore in #783 cleanup test
fix(chat): mark execution dispatched + persist real session_id (#686) (…
74 remaining items
fix(stats): 7d cost sparkline was flat on PostgreSQL — DATE() bucket …
test(execution): migrate #1849 502-detail assertions to the #1853 str…
fix(execution): telemetry + transcript on a failing error_during_exec…
test(uploads): unwind the import-time upload_service stubs after this…
feat(uploads): accept application/zip in chat file uploads (#2152)
test(workspace): the model dropdown's guards (Abilityai/trinity-enter…
fix(workspace): read the roster's runtimes sequentially, and catalog …
test(workspace): the model dropdown's guards (Abilityai/trinity-enter…
fix(workspace): read the roster's runtimes sequentially, and catalog …
test(workspace): the model dropdown's guards (Abilityai/trinity-enter…
fix(workspace): read the roster's runtimes sequentially, and catalog …
feat(workspace): a user-friendly model dropdown in the chat composer (A…
fix(workspace): the audio bridge owns the live-call lease, arms it at…
fix(tests): chain tests pass the harness guards (ent#794)
test(system): chain tests on a rolled-out fleet, with a per-chain go/…