Make test_health portable to scratch clones (no hard dependency on repo-local venv/bin/python) #245

Closed
opened 2026-07-06 10:39:55 -05:00 by jcwalker3 · 0 comments
Owner

Problem

tests/test_health.py::TestMCPHealth::test_startup_conflict_detection spawns <repo>/venv/bin/python by path. In a scratch clone/worktree (now the required reviewer validation environment per #233), there is no venv/, so the test fails:

FileNotFoundError: [Errno 2] No such file or directory: '<scratch-clone>/venv/bin/python'

Observed during post-merge verification of PR #234: full suite in scratch clone = 1 failed, 910 passed, 6 skipped with this as the only failure; same tests pass 3/3 when a venv is present.

Worse: symlinking the dev repo's venv into the scratch clone to work around it makes subprocess-spawning tests hang (spawned children — including an inner pytest -q and the MCP server process — never exit and hold pipes open). Three hung pytest processes had to be killed. So the workaround is a trap, not a fix.

Acceptance criteria

  1. The health test resolves its interpreter portably: prefer sys.executable, else GITEA_TOOLS_TEST_PYTHON env override, else skip with a clear reason (pytest.skip("repo venv not available")) — never a raw FileNotFoundError.
  2. Spawned child processes get explicit timeouts and are terminated in test teardown (no orphaned MCP server / inner pytest holding stdio pipes).
  3. Full suite passes (or cleanly skips the venv-dependent test) in a fresh git clone with only a system Python + installed dev deps.
  4. Reviewer runbook note: scratch-clone validation is the norm; tests must not assume the shared development worktree layout.

Provenance

Reviewer session validating PR #234 in scratch clone r-gt234 at head 4f46655 (2026-07-06). Related: #233 (scratch-clone reviewer wall), #227 (test env isolation).

## Problem `tests/test_health.py::TestMCPHealth::test_startup_conflict_detection` spawns `<repo>/venv/bin/python` by path. In a scratch clone/worktree (now the **required** reviewer validation environment per #233), there is no `venv/`, so the test fails: ``` FileNotFoundError: [Errno 2] No such file or directory: '<scratch-clone>/venv/bin/python' ``` Observed during post-merge verification of PR #234: full suite in scratch clone = `1 failed, 910 passed, 6 skipped` with this as the only failure; same tests pass 3/3 when a venv is present. Worse: symlinking the dev repo's venv into the scratch clone to work around it makes subprocess-spawning tests hang (spawned children — including an inner `pytest -q` and the MCP server process — never exit and hold pipes open). Three hung pytest processes had to be killed. So the workaround is a trap, not a fix. ## Acceptance criteria 1. The health test resolves its interpreter portably: prefer `sys.executable`, else `GITEA_TOOLS_TEST_PYTHON` env override, else skip with a clear reason (`pytest.skip("repo venv not available")`) — never a raw `FileNotFoundError`. 2. Spawned child processes get explicit timeouts and are terminated in test teardown (no orphaned MCP server / inner pytest holding stdio pipes). 3. Full suite passes (or cleanly skips the venv-dependent test) in a fresh `git clone` with only a system Python + installed dev deps. 4. Reviewer runbook note: scratch-clone validation is the norm; tests must not assume the shared development worktree layout. ## Provenance Reviewer session validating PR #234 in scratch clone `r-gt234` at head `4f46655` (2026-07-06). Related: #233 (scratch-clone reviewer wall), #227 (test env isolation).
jcwalker3 added the status:in-progress label 2026-07-06 10:41:32 -05:00
sysadmin removed the status:in-progress label 2026-07-06 11:20:23 -05:00
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

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