Repository navigation
fix(pytest): keep a captured banner from opening a failure block - #4802
viniciusdsandrade wants to merge 2 commits into
Conversation
`filter_pytest_output` starts a new failure at every line that matches `is_block_header`. That match is on the trimmed line and runs inside the captured-stdout section, so a test that prints `_____ stage one _____` or `_ stage two _` shows up as its own `[FAIL]`. pytest's own separator is the line `TerminalWriter.sep` prints at column 0: underscore fills around the title, at least 39 columns. After a captured section, only that separator ends the block. The next failure still splits there, and a banner the test printed stays in the capture.
The banner from rtk-ai#4748 is stdout under a Captured section. The filter keeps the one real failure and its four lines, and drops the phantom entries.
📊 Automated PR Analysis
SummaryFixes a pytest output filter bug where a printed banner in captured stdout (matching the loose block-header pattern) was mistakenly treated as the start of a new failure block, causing later captured lines to be misattributed. The fix tracks when the parser is inside a captured section and only treats a line as a new failure header there if it's an actual pytest-generated separator (based on TerminalWriter.sep's fill-width rules). Review Checklist
Linked issues: #4748 Analyzed automatically by wshm · This is an automated analysis, not a human review. |
Protocol-zero-0
left a comment
There was a problem hiding this comment.
Reviewed exact head 3e29561874807f438136aefafce12568d1d3b7e6 against e05c7bdf with real pytest 9.0.3 on Linux.
The captured stdout/stderr banners no longer become [FAIL] stage one, [FAIL] stage two, or [FAIL] stderr stage. The next genuine failure still has its own entry, location, and diagnostic. I checked terminal widths 40/41/80/120 with short and long tracebacks, a long parametrized ID, an unescaped Unicode ID, colors, setup-error capture, -s, and a passing control: 15 scenarios / 45 native-base-head executions. The -rA control still shows the baseline's separate PASSES/duplicate-summary problem; #4621 covers that state-transition work. This patch removes the captured-banner entries in that control too.
All 61 pytest parser tests, cargo fmt --all --check, and cargo clippy --locked --offline --all-targets -- -D warnings passed. No blocker found in this change. This was a targeted Linux review; the full suite and other platforms were not run.
Summary
Captured stdoutcan matchis_block_header(_____ stage one _____,_ stage two _). The parser treated that line as the next failure, so the banner became its own[FAIL]and later captured lines moved into it.TerminalWriter.sep:_fills around the title, right fill equal to the left or one longer, at least 39 columns. A shorter banner stays in the capture.___ x ___,_ x _) opens a phantom [FAIL] entry #4748.Test plan
test_filter_pytest_captured_banner_is_not_a_failureuses the capture from rtk pytest: a captured line shaped like a block header (___ x ___,_ x _) opens a phantom [FAIL] entry #4748 and expects one entry,[FAIL] test_banner, with the location line and the twoElines.stage one,stage two, andE not an errorare absent.test_filter_pytest_shortened_header_starts_a_blockstill opens the second entry on the long_ nodeid _header, which is outside any captured section.test_filter_pytest_captured_underscore_lines_are_not_headersstill splits on the real separator that follows a captured section.filter_pytest_outputand the fixtures undertests/fixtures/pytest_*.txt(every existing underscore header there is at least 80 columns and still matches). Formatting, clippy, and tests are left to CI.