Skip to content

fix(test): unblock pytest collection — disambiguate test_service.py basenames#1784

Merged
earayu merged 1 commit into
mainfrom
huangheng/wave10-hotfix-pytest-basename-collision
Apr 28, 2026
Merged

fix(test): unblock pytest collection — disambiguate test_service.py basenames#1784
earayu merged 1 commit into
mainfrom
huangheng/wave10-hotfix-pytest-basename-collision

Conversation

@earayu
Copy link
Copy Markdown
Collaborator

@earayu earayu commented Apr 28, 2026

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

  • `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)

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

…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>
@earayu earayu merged commit aa95fab into main Apr 28, 2026
10 checks passed
@earayu earayu deleted the huangheng/wave10-hotfix-pytest-basename-collision branch April 28, 2026 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant