Repository navigation
fix(ci): fail-to-pass reports a replay pytest could not start as could-not-run - #1718
Merged
Merged
Conversation
…d-not-run When pytest could not start on the replayed base tree, devops ci fail-to-pass reported "0 failed and 0 passed ...; 0 errored" as an outcome: a feature passed the check with nothing replayed, and a defect failed it saying no changed test failed on base, though none ran. _run_pytest_on_base dropped pytest's exit status and returned no outcomes when the JUnit report was missing. _run_pytest_on_base now keeps pytest's exit status. An exit of 2 (interrupted), 3 (internal error) or 4 (usage error), or a run that wrote no complete JUnit report, is a ReplayCouldNotRun on the report, with the exit status and the last whole lines of pytest's output that fit in 256 characters. Exit 3 counts with a report too, as pytest writes one holding pytest::internal when an internal error ends a session it had begun to report. A report that is empty or never closes its root testsuites element counts as none: the JUnit parser, still the stdlib HTMLParser, records whether the root closed. Such a replay fails the check for any pull request; the report names the exit status, the replayed test files and pytest's last output, and points to the Fail-to-pass: not applicable line, which still passes the check without replaying. Exit 5, no tests collected, stays an empty replay, and a replay whose tests collect and run reports as before, so a changed test that only fails to collect on base is reported as errored. The command writes an unsatisfied report raw, with markup and emoji codes off, so pytest's output reaches the terminal as pytest wrote it. AGENTS.md and the instruction generator's line say the check fails any pull request whose replay pytest could not run on base, as when the overlaid tests/ import support the base lacks or the pull request changes dependencies or the test harness; that such a pull request declares the not-applicable line; and that a changed test that only fails to collect on base is reported as errored. The could-not-run reports' text is checked against syrupy snapshots, the suite's first, which docs/TESTING.md now names; the trailing-whitespace hook leaves tests/__snapshots__/ alone, as trimming a blank line's indent breaks a snapshot. With part 1 (#1717), the per-test timeout, the narrowed run's worker count and its process-group stop, this completes the item. The task file keeps part 1's section and adds this one as PR 2, with every criterion of the item and both amendments delivered, and changelog.d/1669.md is the item's one fragment, covering both parts. Closes #1669
This was referenced Oct 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The second and last of #1669's pull requests. A fail-to-pass replay whose pytest could not run on the base tree is now reported as "could not run", not as "0 failed, 0 errored". With #1717, this completes #1669.
The defect.
_run_pytest_on_basedropped pytest's exit status and returned no outcomes when the JUnit report was missing. So a replay that never started read as an empty, clean replay:#1312 PR 3 (#1703) hit this: its replayed tests imported a name the base's
srclacked.The fix.
Exit status:
_run_pytest_on_basekeeps pytest's exit status.What counts as "could not run":
It is recorded as
ReplayCouldNotRun, with the exit status and the last whole lines of pytest's output that fit in 256 characters.Exit 3 with a report: it still counts, since pytest writes a report holding
pytest::internalwhen an internal error ends a session it had begun.Broken reports: a report that is empty, or never closes its root
testsuiteselement, counts as no report. The parser is still the stdlib HTMLParser and records whether the root closed.The check: such a replay fails it for any pull request. The report names the exit status, the replayed files and pytest's last output, and points to
Fail-to-pass: not applicable:, which still passes without replaying.Unchanged: exit 5 (no tests collected) stays an empty replay. A replay whose tests collect and run reports as before, so a changed test that only fails to collect on base is reported as errored.
Output: an unsatisfied report is written raw, with markup and emoji codes off, so pytest's output reaches the terminal as written.
Records.
tests/import support the base lacks, and one that changes dependencies or the test harness. Such a PR declares the not-applicable line.docs/TESTING.mdnow names. The trailing-whitespace hook leavestests/__snapshots__/alone, because trimming a blank line breaks a snapshot.changelog.d/1669.mdis the item's one fragment, covering both pull requests.Verification
fail_to_pass.py. Each review fix was shown failing against a planted mutant:feattitle with "0 failed, 0 errored". This code exits 1 with "could not run on base: pytest exited with status 3", plus theImportErrorline.devops ci fail-to-pass --base origin/release/v0.2.37on this branch: 13 changed tests fail on base, and 16 pass.uv run devops cipassed (pre-push hook).Closes #1669