fix(test): add pytest.ini to restrict testpaths and ignore worktree branches (#927) #928

Merged
sysadmin merged 1 commits from fix/issue-927-pytest-config into master 2026-07-27 15:38:45 -05:00
Owner

Closes #927

Closes #927
jcwalker3 added 1 commit 2026-07-25 22:07:37 -05:00
Owner

repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #928
issue: #927
reviewer_identity: sysadmin
profile: prgs-reviewer
session_id: 18879-0f8bad4ac89d
worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr928-17dd05e-s2
phase: claimed
candidate_head: 17dd05ec9d
target_branch: master
target_branch_sha: c30b381eb2
last_activity: 2026-07-27T15:25:44Z
expires_at: 2026-07-27T15:35:44Z
blocker: none

<!-- mcp-review-lease:v1 --> repo: Scaled-Tech-Consulting/Gitea-Tools pr: #928 issue: #927 reviewer_identity: sysadmin profile: prgs-reviewer session_id: 18879-0f8bad4ac89d worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr928-17dd05e-s2 phase: claimed candidate_head: 17dd05ec9dfc761e199cc31cbc47b4a0c4f5df2b target_branch: master target_branch_sha: c30b381eb2756c4ba9cbb2bf7c3f2d6f31b701e7 last_activity: 2026-07-27T15:25:44Z expires_at: 2026-07-27T15:35:44Z blocker: none
sysadmin approved these changes 2026-07-27 10:29:26 -05:00
sysadmin left a comment
Owner

APPROVE — PR #928 at head 17dd05ec9dfc761e199cc31cbc47b4a0c4f5df2b

Independent review by sysadmin / prgs-reviewer; author jcwalker3, so independence holds. Validated in a fresh session-owned worktree branches/review-pr928-17dd05e-s2, detached at exactly this head, clean before and after validation. Merge base 7bf4f1258451823a55b36d2157e74f8457165088; target master re-fetched at c30b381eb2756c4ba9cbb2bf7c3f2d6f31b701e7, and git merge-base --is-ancestor reports the head is not an ancestor, so the already-landed gate does not fire.

Scope

One new file, three lines, exactly what #927 prescribed:

[pytest]
testpaths = tests
norecursedirs = branches .git venv __pycache__ graphify-out

No production code touched. No test touched. Nothing else in the diff.

The fix was proven causal, not assumed

A fresh worktree has no branches/ directory, so #927 cannot reproduce there by simply checking out the base — the absence of the error would prove nothing. I therefore built the reproduction explicitly in a separate diagnostic worktree at the merge base (branches/diag-pr928-base-s2, never the validation worktree), planting a branches/fakewt/ containing duplicate copies of tests/conftest.py, tests/test_worktrees.py, and test_mcp_conn.py:

base (no pytest.ini) + branches/ decoy:
  HINT: remove __pycache__ / .pyc files and/or use a unique basename for your test file modules
  ERROR test_mcp_conn.py
  !!! Interrupted: 1 error during collection !!!
  5533 tests collected, 1 error

same tree, after writing the PR's exact pytest.ini:
  5521 tests collected in 1.30s     (0 errors)

Same tree, same decoy, single variable. The error class matches the one #927 reports; the count differs only because I planted one decoy worktree where the real checkout carries dozens.

Why the two risky properties of this change are safe here

Precedence. A new pytest.ini takes highest precedence and would silently override competing pytest configuration. There is none: no pyproject.toml, setup.cfg, or tox.ini exists in the tree, so nothing is displaced.

testpaths = tests stops collecting the repo-root test_mcp_conn.py. That file is named like a test but is a CLI diagnostic — argparse main(), subprocess.Popen, sys.exit, and no test_-prefixed function or Test-prefixed class anywhere in it. It contributes zero tests, so no coverage is lost. It was in fact one of the modules #927 named as a collection-collision source, and run-tests.sh simply execs python -m pytest "$@", so its behavior improves rather than narrows.

Zero effect on the suite

Full suite at head and at the merge base, each in its own branches/ worktree with pwd and git rev-parse HEAD proof captured inside the same command block as its own pytest invocation:

head 17dd05e : 28 failed, 5487 passed, 6 skipped, 994 subtests in 175.70s
base 7bf4f12 : 28 failed, 5487 passed, 6 skipped, 994 subtests in 177.21s

failing test id sets: comm -23 and comm -13 both empty -> IDENTICAL (28 each)

Every count matches and the failing ids match by identity, not merely by total. The 28 failures are the standing repository baseline and reproduce unchanged at the base, so none originates here. This change alters which paths pytest walks, and demonstrably not which tests run or pass.

Official validation status: baseline-equivalent failure accepted. No validation failure was observed in this session beyond the pre-existing baseline. Both worktrees were clean before and after; no file in either was edited.

Non-blocking observation

norecursedirs replaces pytest's defaults rather than extending them, so build, dist, node_modules, .tox, and the .* hidden-directory pattern are no longer excluded. The impact is negligible because testpaths = tests already confines default collection to tests/, and the explicit branches entry still applies when a path is passed on the command line — which is the case that actually mattered for #927. Worth knowing if testpaths is ever widened.

Canonical PR State

STATE: PR #928 is open at head 17dd05ec9d and now carries a formal APPROVE verdict from sysadmin recorded at that exact head. No blocking finding is open. One non-blocking observation is recorded above.

WHO_IS_NEXT: merger

NEXT_ACTION: A merger session must merge PR #928 at pinned head 17dd05ec9d after merge preflight, having confirmed approval_at_current_head remains true.

NEXT_PROMPT:

Merger session for prgs / Scaled-Tech-Consulting / Gitea-Tools.

Invoke the canonical gitea-workflow skill first. Use the gitea-merger namespace.
Call gitea_allocate_next_work(apply=true, role='merger'). If PR #928 is assigned,
merge only that PR at head 17dd05ec9dfc761e199cc31cbc47b4a0c4f5df2b.

Before merging: confirm approval_at_current_head is true via
gitea_get_pr_review_feedback, run gitea_assess_pr_sync_status and require
recommended_next_action=merge_now, then adopt the reviewer lease with
gitea_adopt_merger_pr_lease pinned to that head. Do not self-select, do not
force-push, and do not update the branch from a merger profile.

Note the base has advanced to c30b381eb2756c4ba9cbb2bf7c3f2d6f31b701e7 since this
head was cut. If sync status returns update_branch_by_merge instead of merge_now,
that is author work and the approval is void at any new head — route for fresh
review rather than merging.

WHAT_HAPPENED: An independent review at the exact head read the entire three-line diff, confirmed no competing pytest configuration exists that the new file could override, and established that the repo-root test_mcp_conn.py excluded by testpaths is a CLI diagnostic contributing zero tests. The fix was proven causal in a separate diagnostic worktree at the merge base by planting duplicate test modules under a branches/ directory, observing the collection error, then writing the PR's exact pytest.ini into the same tree and observing clean collection. The full suite was run at the head and at the merge base in separate worktrees, returning identical pass, fail, skip and subtest counts with identical failing test id sets.

WHY: Issue #927 reports that pytest recurses into branches/, where active worktrees hold duplicate test modules, aborting collection. The change confines default collection to tests/ and excludes branches/, which resolves the reported failure without altering the suite. The two properties that make a new pytest.ini risky in general — overriding existing configuration, and narrowing collection — were each checked and found not to apply here.

ISSUE: #927

HEAD_SHA: 17dd05ec9d

REVIEW_STATUS: APPROVE recorded at 17dd05ec9d by sysadmin

MERGE_READY: yes, subject to merger preflight and sync status at the current head

BLOCKERS: none

VALIDATION: Reviewed in /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr928-17dd05e-s2, created fresh this session, detached at 17dd05ec9d, verified clean by git status --porcelain --untracked-files=all before and after. Target branch master re-fetched from prgs at c30b381eb2756c4ba9cbb2bf7c3f2d6f31b701e7; git merge-base --is-ancestor reports the head is not an ancestor. Diff against merge base 7bf4f12584 is 1 file, +3/-0, adding pytest.ini only. Absence of competing pytest configuration confirmed by listing the tree for pyproject.toml, setup.cfg and tox.ini, none of which exist. The repo-root test_mcp_conn.py was read in full and contains no test-prefixed function or Test-prefixed class, only argparse main, subprocess spawn and sys.exit, so testpaths exclusion removes zero tests. Causal proof of the fix was obtained in a separate diagnostic worktree branches/diag-pr928-base-s2 at the merge base, never in the validation worktree: with a planted branches/fakewt/ holding duplicate copies of tests/conftest.py, tests/test_worktrees.py and test_mcp_conn.py, collection returned 5533 tests collected with 1 error and Interrupted during collection on ERROR test_mcp_conn.py; after writing the PR's exact three-line pytest.ini into that same tree, collection returned 5521 tests collected with zero errors. Full suite at head: 28 failed, 5487 passed, 6 skipped, 994 subtests in 175.70s. Full suite at the merge base in branches/baseline-pr928-7bf4f12-s2: 28 failed, 5487 passed, 6 skipped, 994 subtests in 177.21s. Failing test id sets were captured from each leg in a command block carrying its own cd, pwd and git rev-parse HEAD, then compared with comm in both directions and found identical, so no regression originates from this branch. No file was edited in the validation or baseline worktree; the decoy files and pytest.ini written into the diagnostic worktree are reported under File edits by reviewer and that worktree is removed at completion. Pushes during validation: none.

NATIVE_REVIEW_PROOF: verdict recorded via gitea_submit_pr_review on the native MCP namespace gitea-reviewer, profile prgs-reviewer, identity sysadmin, transport=native_mcp stdio, entrypoint=mcp_server, pid 18879, expected_head_sha 17dd05ec9d, reviewer lease session 18879-0f8bad4ac89d. Every Gitea read and mutation in this review used that same native namespace.

LAST_UPDATED_BY: sysadmin / prgs-reviewer / gitea-reviewer namespace, reviewer lease session 18879-0f8bad4ac89d

## APPROVE — PR #928 at head `17dd05ec9dfc761e199cc31cbc47b4a0c4f5df2b` Independent review by `sysadmin` / `prgs-reviewer`; author `jcwalker3`, so independence holds. Validated in a fresh session-owned worktree `branches/review-pr928-17dd05e-s2`, detached at exactly this head, clean before and after validation. Merge base `7bf4f1258451823a55b36d2157e74f8457165088`; target `master` re-fetched at `c30b381eb2756c4ba9cbb2bf7c3f2d6f31b701e7`, and `git merge-base --is-ancestor` reports the head is not an ancestor, so the already-landed gate does not fire. ### Scope One new file, three lines, exactly what #927 prescribed: ```ini [pytest] testpaths = tests norecursedirs = branches .git venv __pycache__ graphify-out ``` No production code touched. No test touched. Nothing else in the diff. ### The fix was proven causal, not assumed A fresh worktree has no `branches/` directory, so #927 cannot reproduce there by simply checking out the base — the absence of the error would prove nothing. I therefore built the reproduction explicitly in a **separate diagnostic worktree** at the merge base (`branches/diag-pr928-base-s2`, never the validation worktree), planting a `branches/fakewt/` containing duplicate copies of `tests/conftest.py`, `tests/test_worktrees.py`, and `test_mcp_conn.py`: ```text base (no pytest.ini) + branches/ decoy: HINT: remove __pycache__ / .pyc files and/or use a unique basename for your test file modules ERROR test_mcp_conn.py !!! Interrupted: 1 error during collection !!! 5533 tests collected, 1 error same tree, after writing the PR's exact pytest.ini: 5521 tests collected in 1.30s (0 errors) ``` Same tree, same decoy, single variable. The error class matches the one #927 reports; the count differs only because I planted one decoy worktree where the real checkout carries dozens. ### Why the two risky properties of this change are safe here **Precedence.** A new `pytest.ini` takes highest precedence and would silently override competing pytest configuration. There is none: no `pyproject.toml`, `setup.cfg`, or `tox.ini` exists in the tree, so nothing is displaced. **`testpaths = tests` stops collecting the repo-root `test_mcp_conn.py`.** That file is named like a test but is a CLI diagnostic — argparse `main()`, `subprocess.Popen`, `sys.exit`, and no `test_`-prefixed function or `Test`-prefixed class anywhere in it. It contributes zero tests, so no coverage is lost. It was in fact one of the modules #927 named as a collection-collision source, and `run-tests.sh` simply `exec`s `python -m pytest "$@"`, so its behavior improves rather than narrows. ### Zero effect on the suite Full suite at head and at the merge base, each in its own `branches/` worktree with `pwd` and `git rev-parse HEAD` proof captured inside the same command block as its own pytest invocation: ```text head 17dd05e : 28 failed, 5487 passed, 6 skipped, 994 subtests in 175.70s base 7bf4f12 : 28 failed, 5487 passed, 6 skipped, 994 subtests in 177.21s failing test id sets: comm -23 and comm -13 both empty -> IDENTICAL (28 each) ``` Every count matches and the failing ids match by identity, not merely by total. The 28 failures are the standing repository baseline and reproduce unchanged at the base, so none originates here. This change alters which *paths pytest walks*, and demonstrably not which tests run or pass. Official validation status: `baseline-equivalent failure accepted`. No validation failure was observed in this session beyond the pre-existing baseline. Both worktrees were clean before and after; no file in either was edited. ### Non-blocking observation `norecursedirs` replaces pytest's defaults rather than extending them, so `build`, `dist`, `node_modules`, `.tox`, and the `.*` hidden-directory pattern are no longer excluded. The impact is negligible because `testpaths = tests` already confines default collection to `tests/`, and the explicit `branches` entry still applies when a path is passed on the command line — which is the case that actually mattered for #927. Worth knowing if `testpaths` is ever widened. ## Canonical PR State STATE: PR #928 is open at head 17dd05ec9dfc761e199cc31cbc47b4a0c4f5df2b and now carries a formal APPROVE verdict from sysadmin recorded at that exact head. No blocking finding is open. One non-blocking observation is recorded above. WHO_IS_NEXT: merger NEXT_ACTION: A merger session must merge PR #928 at pinned head 17dd05ec9dfc761e199cc31cbc47b4a0c4f5df2b after merge preflight, having confirmed approval_at_current_head remains true. NEXT_PROMPT: ```text Merger session for prgs / Scaled-Tech-Consulting / Gitea-Tools. Invoke the canonical gitea-workflow skill first. Use the gitea-merger namespace. Call gitea_allocate_next_work(apply=true, role='merger'). If PR #928 is assigned, merge only that PR at head 17dd05ec9dfc761e199cc31cbc47b4a0c4f5df2b. Before merging: confirm approval_at_current_head is true via gitea_get_pr_review_feedback, run gitea_assess_pr_sync_status and require recommended_next_action=merge_now, then adopt the reviewer lease with gitea_adopt_merger_pr_lease pinned to that head. Do not self-select, do not force-push, and do not update the branch from a merger profile. Note the base has advanced to c30b381eb2756c4ba9cbb2bf7c3f2d6f31b701e7 since this head was cut. If sync status returns update_branch_by_merge instead of merge_now, that is author work and the approval is void at any new head — route for fresh review rather than merging. ``` WHAT_HAPPENED: An independent review at the exact head read the entire three-line diff, confirmed no competing pytest configuration exists that the new file could override, and established that the repo-root test_mcp_conn.py excluded by testpaths is a CLI diagnostic contributing zero tests. The fix was proven causal in a separate diagnostic worktree at the merge base by planting duplicate test modules under a branches/ directory, observing the collection error, then writing the PR's exact pytest.ini into the same tree and observing clean collection. The full suite was run at the head and at the merge base in separate worktrees, returning identical pass, fail, skip and subtest counts with identical failing test id sets. WHY: Issue #927 reports that pytest recurses into branches/, where active worktrees hold duplicate test modules, aborting collection. The change confines default collection to tests/ and excludes branches/, which resolves the reported failure without altering the suite. The two properties that make a new pytest.ini risky in general — overriding existing configuration, and narrowing collection — were each checked and found not to apply here. ISSUE: #927 HEAD_SHA: 17dd05ec9dfc761e199cc31cbc47b4a0c4f5df2b REVIEW_STATUS: APPROVE recorded at 17dd05ec9dfc761e199cc31cbc47b4a0c4f5df2b by sysadmin MERGE_READY: yes, subject to merger preflight and sync status at the current head BLOCKERS: none VALIDATION: Reviewed in /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr928-17dd05e-s2, created fresh this session, detached at 17dd05ec9dfc761e199cc31cbc47b4a0c4f5df2b, verified clean by git status --porcelain --untracked-files=all before and after. Target branch master re-fetched from prgs at c30b381eb2756c4ba9cbb2bf7c3f2d6f31b701e7; git merge-base --is-ancestor reports the head is not an ancestor. Diff against merge base 7bf4f1258451823a55b36d2157e74f8457165088 is 1 file, +3/-0, adding pytest.ini only. Absence of competing pytest configuration confirmed by listing the tree for pyproject.toml, setup.cfg and tox.ini, none of which exist. The repo-root test_mcp_conn.py was read in full and contains no test-prefixed function or Test-prefixed class, only argparse main, subprocess spawn and sys.exit, so testpaths exclusion removes zero tests. Causal proof of the fix was obtained in a separate diagnostic worktree branches/diag-pr928-base-s2 at the merge base, never in the validation worktree: with a planted branches/fakewt/ holding duplicate copies of tests/conftest.py, tests/test_worktrees.py and test_mcp_conn.py, collection returned 5533 tests collected with 1 error and Interrupted during collection on ERROR test_mcp_conn.py; after writing the PR's exact three-line pytest.ini into that same tree, collection returned 5521 tests collected with zero errors. Full suite at head: 28 failed, 5487 passed, 6 skipped, 994 subtests in 175.70s. Full suite at the merge base in branches/baseline-pr928-7bf4f12-s2: 28 failed, 5487 passed, 6 skipped, 994 subtests in 177.21s. Failing test id sets were captured from each leg in a command block carrying its own cd, pwd and git rev-parse HEAD, then compared with comm in both directions and found identical, so no regression originates from this branch. No file was edited in the validation or baseline worktree; the decoy files and pytest.ini written into the diagnostic worktree are reported under File edits by reviewer and that worktree is removed at completion. Pushes during validation: none. NATIVE_REVIEW_PROOF: verdict recorded via gitea_submit_pr_review on the native MCP namespace gitea-reviewer, profile prgs-reviewer, identity sysadmin, transport=native_mcp stdio, entrypoint=mcp_server, pid 18879, expected_head_sha 17dd05ec9dfc761e199cc31cbc47b4a0c4f5df2b, reviewer lease session 18879-0f8bad4ac89d. Every Gitea read and mutation in this review used that same native namespace. LAST_UPDATED_BY: sysadmin / prgs-reviewer / gitea-reviewer namespace, reviewer lease session 18879-0f8bad4ac89d
Owner

repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #928
issue: #927
reviewer_identity: sysadmin
profile: prgs-reviewer
session_id: 18879-0f8bad4ac89d
worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr928-17dd05e-s2
phase: released
candidate_head: 17dd05ec9d
target_branch: master
target_branch_sha: c30b381eb2
last_activity: 2026-07-27T15:29:43Z
expires_at: 2026-07-27T15:39:43Z
blocker: manual-release

<!-- mcp-review-lease:v1 --> repo: Scaled-Tech-Consulting/Gitea-Tools pr: #928 issue: #927 reviewer_identity: sysadmin profile: prgs-reviewer session_id: 18879-0f8bad4ac89d worktree: /Users/jasonwalker/Development/Gitea-Tools/branches/review-pr928-17dd05e-s2 phase: released candidate_head: 17dd05ec9dfc761e199cc31cbc47b4a0c4f5df2b target_branch: master target_branch_sha: c30b381eb2756c4ba9cbb2bf7c3f2d6f31b701e7 last_activity: 2026-07-27T15:29:43Z expires_at: 2026-07-27T15:39:43Z blocker: manual-release
Owner

repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #928
issue: #927
reviewer_identity: sysadmin
profile: prgs-merger
session_id: 47587-87b640aebf83
worktree: /Users/jasonwalker/Development/Gitea-Tools
phase: claimed
candidate_head: 17dd05ec9d
target_branch: master
target_branch_sha: 5fea326988
last_activity: 2026-07-27T20:37:55Z
expires_at: 2026-07-27T20:47:55Z
blocker: none

<!-- mcp-review-lease:v1 --> repo: Scaled-Tech-Consulting/Gitea-Tools pr: #928 issue: #927 reviewer_identity: sysadmin profile: prgs-merger session_id: 47587-87b640aebf83 worktree: /Users/jasonwalker/Development/Gitea-Tools phase: claimed candidate_head: 17dd05ec9dfc761e199cc31cbc47b4a0c4f5df2b target_branch: master target_branch_sha: 5fea326988d9097a60043ce1c891ff7b7bdacae7 last_activity: 2026-07-27T20:37:55Z expires_at: 2026-07-27T20:47:55Z blocker: none
sysadmin merged commit ed9414ebda into master 2026-07-27 15:38:45 -05:00
Owner

repo: Scaled-Tech-Consulting/Gitea-Tools
pr: #928
issue: #927
reviewer_identity: sysadmin
profile: prgs-merger
session_id: 47587-87b640aebf83
worktree: /Users/jasonwalker/Development/Gitea-Tools
phase: released
candidate_head: 17dd05ec9d
target_branch: master
target_branch_sha: 5fea326988
last_activity: 2026-07-27T20:46:07Z
expires_at: 2026-07-27T20:56:07Z
blocker: post-merge-moot

<!-- mcp-review-lease:v1 --> repo: Scaled-Tech-Consulting/Gitea-Tools pr: #928 issue: #927 reviewer_identity: sysadmin profile: prgs-merger session_id: 47587-87b640aebf83 worktree: /Users/jasonwalker/Development/Gitea-Tools phase: released candidate_head: 17dd05ec9dfc761e199cc31cbc47b4a0c4f5df2b target_branch: master target_branch_sha: 5fea326988d9097a60043ce1c891ff7b7bdacae7 last_activity: 2026-07-27T20:46:07Z expires_at: 2026-07-27T20:56:07Z blocker: post-merge-moot
Sign in to join this conversation.
No Reviewers
No labels
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

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