fix(pytest): surface collection errors instead of 'No tests collected'#2850
Open
mariofeter wants to merge 1 commit into
Open
fix(pytest): surface collection errors instead of 'No tests collected'#2850mariofeter wants to merge 1 commit into
mariofeter wants to merge 1 commit into
Conversation
The pytest summarizer returned 'Pytest: No tests collected' whenever the summary line had no passed/failed/skipped counts, hiding collection errors (ImportError/SyntaxError in test modules) and swallowing non-session output like --version. Exactly the RED case TDD relies on. - parse 'N error(s)' counts from summary lines (=== wrapped and -q bare) - treat the ERRORS section like FAILURES so tracebacks are collected - render ERROR entries with [ERR] tag and an 'Errors:' section header - prioritize '>'/'E' root-cause lines over traceback boilerplate within the 3-line cap - pass through unrecognized non-session output (--version, --help) instead of mislabeling it; 'No tests collected' now requires pytest to have actually said so - skip '!!! Interrupted !!!' banner lines in failure details Real pytest 9 fixture included (--tb=short -q -rxX collection error).
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.
Problem
The pytest summarizer returns
Pytest: No tests collectedwhenever the summary line contains no passed/failed/skipped counts. This hides:ERRORSsection and1 error in 0.06s, exits 2 — rtk reports "No tests collected" and the root cause is lost. This is exactly the RED case TDD workflows rely on.rtk pytest --versionalso reports "No tests collected" instead of the version string.Repro (pytest 9, real output fixture included):
Fix
parse_summary_linenow parsesN error(s)counts (both=== 1 error in 0.12s ===and bare-q1 error in 0.06s; the bare form requires a leading integer so traceback prose can't masquerade as a summary line)ERRORSsection is treated likeFAILURES, so collection tracebacks are capturedErrors:header with an[ERR]tag>/Emarkers) are selected before traceback location boilerplate within the existing 3-line cap, soE ModuleNotFoundError: ...always survives--version,--help, plugin banners) is passed through unchanged; "No tests collected" now requires pytest to have actually said so (no tests ran/collected 0 items)!!! Interrupted !!!banners are skipped in failure details (the error count already lands in the header)test_filescollection (was already unused:_test_files)After
Green runs are unchanged (
Pytest: N passed), normal assertion failures unchanged.Test plan
--versionpassthrough,parse_summary_lineerror countscargo fmt --all && cargo clippy --all-targetsclean--version