fix(test): unblock pytest collection — disambiguate test_service.py basenames#1784
Merged
Merged
Conversation
…e test_service.py basenames ## Root cause Direct-to-main commit `a42bc0a` (2026-04-28 15:42, "fix: restore knowledge graph page loading") added ``tests/unit_test/domains/knowledge_graph/test_service.py`` which collides at the basename level with the existing ``tests/unit_test/graph_curation/test_service.py`` (Wave 7 graph curation tests). Neither directory had an ``__init__.py``, so pytest's default ``rootdir`` import mode uses module basename only and rejects two files with the same basename: ``` ERROR collecting tests/unit_test/graph_curation/test_service.py Multiple test files with basename test_service.py: - tests/unit_test/domains/knowledge_graph/test_service.py - tests/unit_test/graph_curation/test_service.py HINT: remove __pycache__ / .pyc files and/or use a unique basename for your test file modules ``` The collection failure short-circuits ``make test-unit``, taking the ``lint-and-unit`` CI lane red on every PR opened against the broken main HEAD (visible on Wave 10 chunk A PR #1783 and any subsequent PR). ## Fix Add an empty ``__init__.py`` to each colliding test directory. This switches pytest from basename-only module naming to full-package-path naming (``tests.unit_test.domains.knowledge_graph.test_service`` vs ``tests.unit_test.graph_curation.test_service``), eliminating the collision. This is the pytest-recommended fix for this exact error class — see the ``HINT`` line in the error message above. The fix is purely additive (2 empty files) and preserves all existing test discovery and execution. ## Verification - ``uv run pytest tests/unit_test/ -q --collect-only`` → 1187 tests collected, no errors (was: 1 error during collection) - ``uv run pytest tests/unit_test/ -q`` → **1172 passed, 15 skipped** in 55.51s (full suite green) - ``uvx ruff check`` / ``uvx ruff format --check`` clean (no Python source changes, only empty files added) ## Why a hot-fix PR (not direct-to-main) Per Wave 9 own-up #10 SOP (sedimented in ``feedback_cr_spec_crosscheck.md``): merges go through PR + ``gh pr checks`` explicit verify. ``a42bc0a`` was a direct-to-main push that bypassed this gate entirely; this hot-fix follows the SOP so the fix itself goes through CI before merge. Architect ratify (msg=deceec7d) endorsed Option A (``__init__.py``) over Option B (rename). ## Unblocks - Bryce Wave 10 chunk A PR #1783 ``lint-and-unit`` (currently red because of this collision, not because of chunk A's schema migration) - All other in-flight PRs whose CI is sharing the broken main HEAD baseline Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This was referenced Apr 28, 2026
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.
Root cause
Direct-to-main commit `a42bc0a` (2026-04-28 15:42, "fix: restore knowledge graph page loading") added `tests/unit_test/domains/knowledge_graph/test_service.py` which collides at the basename level with the existing `tests/unit_test/graph_curation/test_service.py` (Wave 7 graph curation tests). Neither directory had an `init.py`, so pytest's default rootdir import mode uses module basename only and rejects two files with the same basename:
```
ERROR collecting tests/unit_test/graph_curation/test_service.py
Multiple test files with basename test_service.py
HINT: remove pycache / .pyc files and/or use a unique basename for your test file modules
```
The collection failure short-circuits `make test-unit`, taking the `lint-and-unit` CI lane red on every PR opened against the broken main HEAD (visible on Wave 10 chunk A PR #1783 and any subsequent PR).
Fix
Add an empty `init.py` to each colliding test directory. This switches pytest from basename-only module naming to full-package-path naming (`tests.unit_test.domains.knowledge_graph.test_service` vs `tests.unit_test.graph_curation.test_service`), eliminating the collision.
Pytest-recommended fix for this exact error class. Purely additive (2 empty files), preserves all existing test discovery + execution.
Verification
Why a hot-fix PR (not direct-to-main)
Per Wave 9 own-up #10 SOP (sedimented in `feedback_cr_spec_crosscheck.md`): merges go through PR + `gh pr checks` explicit verify. `a42bc0a` was a direct-to-main push that bypassed this gate entirely; this hot-fix follows the SOP so the fix itself goes through CI before merge. Architect ratify (msg=deceec7d in #summary:6ef52041) endorsed Option A (`init.py`) over Option B (rename).
Unblocks
🤖 Generated with Claude Code