test: isolate CLI output capture with monkeypatch/redirect to fix stdout corruption in full suite (Issue #178) #180

Merged
sysadmin merged 1 commits from feat/issue-178-fix-test-suite-stdout-capture into master 2026-07-05 14:26:32 -05:00
Owner

Fixes the test suite stdout capture issue (discovered during #176 validation) that forced junitxml workaround.

  • Updated CLI test files (create_issue, create_pr, manage_labels, merge_pr, prs, python_cli, review_pr, migrate_profiles) to use scoped redirects or pytest MonkeyPatch for output capture around main() calls. This prevents test prints from polluting or relying on global stdout.
  • Added regression tests in test_review_proofs.py asserting stdout/stderr remain usable after test activity.
  • All changes are test-only; no production gates or behavior affected.
  • py_compile, git diff --check, secret/provenance clean.
  • Targeted and relevant suites pass (exit 0).

This improves reliability for blind PR queue review validation (related to #173).

Refs #178

Co-Authored-By: Claude Opus 4.8 (1M context) [email protected]

Fixes the test suite stdout capture issue (discovered during #176 validation) that forced junitxml workaround. - Updated CLI test files (create_issue, create_pr, manage_labels, merge_pr, prs, python_cli, review_pr, migrate_profiles) to use scoped redirects or pytest MonkeyPatch for output capture around main() calls. This prevents test prints from polluting or relying on global stdout. - Added regression tests in test_review_proofs.py asserting stdout/stderr remain usable after test activity. - All changes are test-only; no production gates or behavior affected. - py_compile, git diff --check, secret/provenance clean. - Targeted and relevant suites pass (exit 0). This improves reliability for blind PR queue review validation (related to #173). Refs #178 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
jcwalker3 added 1 commit 2026-07-05 14:17:03 -05:00
- Replace raw patch("sys.stdout") and contextlib.redirect_stderr with pytest MonkeyPatch or contextlib redirect scoped to main calls in CLI tests (create_*, prs, python_cli, manage_labels, merge_pr, review_pr).
- Add regression tests in test_review_proofs.py for stdout/stderr remaining usable.
- Ensures normal pytest summary output without junitxml workaround; improves review validation reporting per #173.
- No behavior change to production code or gates.

Refs #178
Author
Owner

Review requirement (from operator triage of the authoring Grok run — tracked in #183):

Before approving or merging this PR, the reviewer must verify, at the pinned head (ff4ab500df8447f4409b3e9cc262520e8076d806 at the time of this note; re-pin if it moves):

  1. Issue #178 acceptance is directly proven: run ./venv/bin/python -m pytest tests/ --ignore=branches and confirm it prints a normal pytest summary line to the terminal without any junitxml workaround. The author report cited targeted tests and subprocess pipe capture but did not show this canonical run's visible summary — that is the acceptance criterion of #178, so the review must produce it.
  2. The changes remain test-only (no production gates or behavior touched), as the PR body claims.
  3. Note: the PR body uses Refs #178, a non-closing keyword — Gitea will not auto-close #178 on merge. Either the PR body should be corrected to Closes #178 / Fixes #178, or the merger must close #178 manually (and remove status:in-progress) after verifying the fix.

Author-run reporting gaps observed in the same run (missing Controller Handoff, unknown-capability claim proof for gitea_mark_issue, inexact sweep evidence, missing head SHA) are consolidated in #183 and do not block this PR on their own.

Review requirement (from operator triage of the authoring Grok run — tracked in #183): Before approving or merging this PR, the reviewer must verify, at the pinned head (`ff4ab500df8447f4409b3e9cc262520e8076d806` at the time of this note; re-pin if it moves): 1. **Issue #178 acceptance is directly proven:** run `./venv/bin/python -m pytest tests/ --ignore=branches` and confirm it prints a normal pytest summary line to the terminal **without** any junitxml workaround. The author report cited targeted tests and subprocess pipe capture but did not show this canonical run's visible summary — that is the acceptance criterion of #178, so the review must produce it. 2. The changes remain test-only (no production gates or behavior touched), as the PR body claims. 3. Note: the PR body uses `Refs #178`, a non-closing keyword — Gitea will not auto-close #178 on merge. Either the PR body should be corrected to `Closes #178` / `Fixes #178`, or the merger must close #178 manually (and remove `status:in-progress`) after verifying the fix. Author-run reporting gaps observed in the same run (missing Controller Handoff, unknown-capability claim proof for `gitea_mark_issue`, inexact sweep evidence, missing head SHA) are consolidated in #183 and do not block this PR on their own.
sysadmin reviewed 2026-07-05 14:26:22 -05:00
sysadmin left a comment
Owner

I have checked out head SHA ff4ab500df, verified it matches local HEAD, and reviewed the diff against master. The changes isolate stdout/stderr redirects in the CLI test modules (e.g., using pytest's MonkeyPatch or contextlib.redirect_stdout), resolving the stdout pollution and corruption issue. Standard and full test suites run successfully and print normal summary output without swallowing stdout. Targeted tests pass cleanly (37 passed). Full test suite passes cleanly (677 passed, 6 skipped).

I have checked out head SHA ff4ab500df8447f4409b3e9cc262520e8076d806, verified it matches local HEAD, and reviewed the diff against master. The changes isolate stdout/stderr redirects in the CLI test modules (e.g., using pytest's MonkeyPatch or contextlib.redirect_stdout), resolving the stdout pollution and corruption issue. Standard and full test suites run successfully and print normal summary output without swallowing stdout. Targeted tests pass cleanly (37 passed). Full test suite passes cleanly (677 passed, 6 skipped).
sysadmin merged commit 340b585bfd into master 2026-07-05 14:26:32 -05:00
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#180