pytest test collection fails with 199 errors due to recursing into branches directory #927

Open
opened 2026-07-25 22:06:17 -05:00 by jcwalker3 · 0 comments
Owner

Environment & Symptom

Running ./run-tests.sh or pytest fails during test collection with 199 errors (_pytest.pathlib.ImportPathMismatchError).

Root Cause

pytest defaults to recursing through all subdirectories in the repository root. The branches/ directory contains active git worktrees and branch checkouts, each with duplicate test modules (tests/conftest.py, test_mcp_conn.py, etc.). As a result, pytest encounters duplicate module import names and aborts test collection.

Recommended Fix

  1. Add a pytest.ini file in the repository root configuring:
[pytest]
testpaths = tests
norecursedirs = branches .git venv __pycache__ graphify-out
  1. Verify ./run-tests.sh executes test suite cleanly without collecting worktree branches.
### Environment & Symptom Running `./run-tests.sh` or `pytest` fails during test collection with 199 errors (`_pytest.pathlib.ImportPathMismatchError`). ### Root Cause `pytest` defaults to recursing through all subdirectories in the repository root. The `branches/` directory contains active git worktrees and branch checkouts, each with duplicate test modules (`tests/conftest.py`, `test_mcp_conn.py`, etc.). As a result, `pytest` encounters duplicate module import names and aborts test collection. ### Recommended Fix 1. Add a `pytest.ini` file in the repository root configuring: ```ini [pytest] testpaths = tests norecursedirs = branches .git venv __pycache__ graphify-out ``` 2. Verify `./run-tests.sh` executes test suite cleanly without collecting worktree branches.
jcwalker3 added the bug label 2026-07-25 22:06:17 -05:00
Sign in to join this conversation.
No labels bug
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Scaled-Tech-Consulting/Gitea-Tools#927