Repository navigation
Conversation
pytest runs that end in errors (broken fixtures, collection errors)
were summarized with no error indication at all:
- "20 passed, 1 error in 1.94s" became "Pytest: 20 passed" — the
all-green short form — while the exit code stayed 1.
- "Interrupted: 1 error during collection" (exit 2) became
"Pytest: No tests collected", which is misleading.
- "=== ERRORS ===" detail blocks were never captured, so the cause of
setup/collection errors was invisible in the filtered output.
Fixes:
- parse "N error(s)" in the summary line (=== wrapped and -q bare forms)
- never take the all-green short form when errors were counted or any
failure detail was collected
- treat "=== ERRORS ===" sections like FAILURES so error detail blocks
are preserved
- render short-summary "ERROR ..." entries, which previously rendered
as empty items
- anchor -q bare summary detection on the full summary grammar
("<N> <category>[, ...] in <duration>s") instead of substrings, and
let the last match win: captured stdout of failing tests flows
through the same scan, so prose like "retrying after error in
connection pool" (or a verbatim inner pytest summary printed by a
test driving pytest itself) must never displace the real footer
yunancun
force-pushed
the
fix/pytest-error-count
branch
from
June 11, 2026 18:44
8a87a1e to
32561a0
Compare
Contributor
|
This pull request has been automatically marked as stale due to 90 days of inactivity. If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. Your contribution is very much appreciated — we're sorry we haven't been able to review it yet. |
7 tasks done
1 of 3 tasks
Contributor
|
Closing this pull request after a prolonged period of inactivity. If this is still relevant, please ask for it to be reopened. Thank you! |
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.
Summary
rtk pytestsilently drops pytest error counts: a run ending in20 passed, 1 error in 1.94s(exit code 1) is summarized as the all-greenPytest: 20 passed. Errors (broken fixtures, setup/teardown errors) are invisible unless the caller checks the exit code and digs into the tee log.Interrupted: 1 error during collection, exit code 2) are reported asPytest: No tests collected, which is misleading.=== ERRORS ===detail blocks were never captured by the state machine, so the cause of an error never appeared in the filtered output (and singleERROR ...short-summary entries rendered as empty items).This fix makes
parse_summary_linecountN error(s), blocks the all-green short form whenever errors were counted (or any failure detail was collected), captures=== ERRORS ===sections likeFAILURES, and rendersERROR ...short-summary entries with an[ERROR]label.Reproduction (before → after, rtk built from
develop@ 6785a6c)Broken fixture (
pytestexits 1, prints20 passed, 1 error in 1.94s):Collection error (
pytestexits 2):Mixed (
2 failed, 7 passed, 1 error in 0.02s):All-green runs are unchanged (
Pytest: 5 passed, byte-identical to before), and exit codes pass through untouched as before.For agent workflows this matters because the compressed summary is the only thing the LLM reads: an "all passed" line for a run that actually had errors leads the agent to conclude the suite is green ("Correctness VS Token Savings").
Review update: anchored
-qbare-summary detectionAdversarial review of the first revision of this PR found a regression it introduced: the
-qbare-summary heuristic matched on substrings (contains(" error") … && contains(" in ")), so captured stdout of a failing test containing prose likeretrying after error in connection poolwas mistaken for the summary line, displacing the real footer and reporting a red run asPytest: No tests collected.The same false-capture already exists on
developfor the pre-existingpassed/failed/skippedarms — stdout prose likeworker 3 passed in shard cleanupmakes unpatched rtk report a false all-greenPytest: 3 passed(exit 1, zero failure detail shown) for a red run.This revision replaces the substring checks with a structural matcher (
is_bare_summary_line): every comma-separated stat must have the<count> <category>shape and the line must end inin <duration>s(with pytest's optional(h:mm:ss)suffix for runs over 60s). Capture is also last-match-wins instead of first-match-wins — the genuine footer is always the final such line of a pytest run, so even a verbatim inner pytest summary printed by a test that itself drives pytest can no longer pin the summary slot. Both bait shapes (the regression and the pre-existing one) now producePytest: 1 passed, 1 failedplus failure detail, matching native pytest.Test plan
cargo fmt --all --check && cargo clippy --all-targets && cargo test— clippy clean, full suite 2157 passed / 0 failed (base before this change: 2150 passed / 0 failed; the +7 are the new tests below)pytest_cmd.rs:test_parse_summary_line_errors(singular/plural/error-only/mixed summary lines),test_filter_pytest_errors_not_collapsed_to_all_green,test_filter_pytest_collection_error,test_filter_pytest_mixed_failures_and_errors— all 4 fail on the unpatched code (verified by reverting the parse branch), pass with the fixtest_is_bare_summary_line_anchoring(real footer shapes incl.(h:mm:ss)accepted; stdout prose,===-wrapped andFAILED ...lines rejected),test_filter_pytest_stdout_prose_not_mistaken_for_summary,test_filter_pytest_verbatim_inner_summary_in_stdout— verified to fail when the anchoring is reverted to substring matching, pass with the fixrtk pytestrun against five real scenario repos (broken fixture / import error during collection / mixed pass+fail+error / stdout containing...error in...prose / stdout containing...passed in...prose) and one all-green repo, compared side by side with nativepytest -qoutput and exit codes (outputs above)🤖 Generated with Claude Code