Skip to content

Include reruns in -ra/-rA short test summary - #373

Open
LouisDeconinck wants to merge 2 commits into
pytest-dev:masterfrom
LouisDeconinck:issue-45-ra-reruns
Open

LouisDeconinck wants to merge 2 commits into
pytest-dev:masterfrom
LouisDeconinck:issue-45-ra-reruns

Conversation

@LouisDeconinck

@LouisDeconinck LouisDeconinck commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • -ra/-rA ("all") now shows the rerun test summary info section, without requiring -rR
  • pytest expands the a/A reportchars before they reach the terminal reporter, so the plugin now checks the raw -r option for a/A in addition to the explicit r/R

Closes #45

Test plan

  • Added parametrized test covering -ra and -rA producing the rerun summary section
  • Existing -rR summary tests still pass

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>
Comment on lines +1339 to +1343
# -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):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
# -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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rerun tests are not reported with "all" setting

2 participants