Conversation
conftest.py read PYTEST_XDIST_WORKER_ID to name each xdist worker's isolated SQLite file, but xdist actually sets PYTEST_XDIST_WORKER (e.g. "gw0"). The wrong name always fell back to "master", so every worker's DB file was labeled identically even though each worker still gets its own tempfile.mkdtemp() directory (isolation was not broken, but per-worker DB files were indistinguishable when debugging). Verified in isolation this does not fully explain the "Run tests with coverage" flake seen on main and on PRs (sqlalchemy.exc.OperationalError: unable to open database file / no such table under `-n auto`) — that flake persists after this fix and is tracked separately. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tests/conftest.pyreadPYTEST_XDIST_WORKER_IDto name each xdist worker's isolated SQLite temp DB file, but pytest-xdist actually setsPYTEST_XDIST_WORKER(e.g.gw0) — confirmed by readingxdist/remote.py. The wrong name always fell back to"master", so every worker's DB filename was identical even though isolation itself wasn't broken (each worker still gets its owntempfile.mkdtemp()directory).Context: this does NOT fix the CI flake blocking the auto-work queue
While investigating issue #311 (which has 10+ closed/duplicate PRs, all failing CI), I found that the
Run tests with coverageCI step is broken onmainitself — not just on PRs. Repro:fails non-deterministically with
sqlalchemy.exc.OperationalError: unable to open database file/no such table: sessions, always in API route test files that share the process-lifetimeapp_context.engine/app_context.async_session_makersingletons.I tested two hypotheses:
NullPool(to rule out aiosqlite connections bound to a stale pytest-asyncio per-test event loop) — also did not resolve it.Filing a separate issue with full repro notes and both ruled-out hypotheses so the next session doesn't repeat this investigation from scratch.
Test plan
ruff check .— all checks passedpython3 -m pytest -q -m 'not e2e'— 3171 passed, 34 skipped, 46 deselected