Include reruns in -ra/-rA short test summary - #373
LouisDeconinck wants to merge 2 commits into
Conversation
pytest expands the "a"/"A" reportchars before they reach the terminal reporter, so the plugin's rerun summary was never shown for `pytest -ra`. Check the raw -r option for a/A as well as the explicit r/R. Closes pytest-dev#45. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
| # -rR selects reruns explicitly; -ra/-rA ("all") should include them too, | ||
| # but pytest expands those flags before tr.reportchars is set, so check the | ||
| # raw option instead. | ||
| requested = tr.config.option.reportchars | ||
| if not show_tracebacks and not any(c in "rRaA" for c in requested): |
There was a problem hiding this comment.
Reading the raw -r option bypasses pytest's N reset, so the rerun summary now escapes a reset that used to suppress it.
getreportopt() treats N as "reset the list": for -raN it first expands a and then clears everything, leaving reportopts == "". Since this check only scans the raw string for any of rRaA, the a still matches and the section is printed.
Confirmed against pytest 9.1.1 with a flaky test and --reruns 1:
| flags | master | this PR |
|---|---|---|
-raN |
no section | section printed |
-ra |
no section | section printed (intended) |
Honouring only the part after the last N matches pytest's own semantics, and keeping tr.reportchars in the check preserves the explicit R path (plus anything that appends to reportchars at runtime). Full suite (252 tests) passes with this, -raN goes back to printing nothing, and -rNa still prints — consistent with pytest, which reports after a reset too.
| # -rR selects reruns explicitly; -ra/-rA ("all") should include them too, | |
| # but pytest expands those flags before tr.reportchars is set, so check the | |
| # raw option instead. | |
| requested = tr.config.option.reportchars | |
| if not show_tracebacks and not any(c in "rRaA" for c in requested): | |
| # -rR selects reruns explicitly; -ra/-rA ("all") should include them too, | |
| # but pytest expands those flags before tr.reportchars is set, so check the | |
| # raw option as well. "N" resets the list, so only honour what follows the | |
| # last reset. | |
| requested = tr.reportchars + tr.config.option.reportchars.rsplit("N", 1)[-1] | |
| if not show_tracebacks and not any(c in "rRaA" for c in requested): |
— Comment created by Claude
Summary
-ra/-rA("all") now shows thererun test summary infosection, without requiring-rRa/Areportchars before they reach the terminal reporter, so the plugin now checks the raw-roption fora/Ain addition to the explicitr/RCloses #45
Test plan
-raand-rAproducing the rerun summary section-rRsummary tests still pass