From d183ebdce08bc95d0d980a794e036951f3ff2604 Mon Sep 17 00:00:00 2001 From: Louis Deconinck Date: Thu, 17 Sep 2026 21:23:42 +0200 Subject: [PATCH] Include reruns in -ra/-rA short test summary 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 #45. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- changes/45.feature.rst | 3 +++ src/pytest_rerunfailures.py | 6 +++++- tests/test_pytest_rerunfailures.py | 13 +++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 changes/45.feature.rst diff --git a/changes/45.feature.rst b/changes/45.feature.rst new file mode 100644 index 00000000..3c0be12d --- /dev/null +++ b/changes/45.feature.rst @@ -0,0 +1,3 @@ +Include reruns in the summary when ``-ra``/``-rA`` ("all") is passed, so +``pytest -ra`` now shows the ``rerun test summary info`` section without +requiring ``-rR``. diff --git a/src/pytest_rerunfailures.py b/src/pytest_rerunfailures.py index 616e658b..54dc91bd 100644 --- a/src/pytest_rerunfailures.py +++ b/src/pytest_rerunfailures.py @@ -1336,7 +1336,11 @@ def pytest_terminal_summary(terminalreporter): # Adapted from https://pytest.org/latest/_modules/_pytest/skipping.html tr = terminalreporter show_tracebacks = tr.config.getoption("rerun_show_tracebacks", False) - if not show_tracebacks and not any(c in "rR" for c in tr.reportchars): + # -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): return lines = show_rerun(terminalreporter, show_tracebacks=show_tracebacks) diff --git a/tests/test_pytest_rerunfailures.py b/tests/test_pytest_rerunfailures.py index a4208c50..b1d8b6d8 100644 --- a/tests/test_pytest_rerunfailures.py +++ b/tests/test_pytest_rerunfailures.py @@ -693,6 +693,19 @@ def test_skips(bad_teardown): ] +@pytest.mark.parametrize("report_flag", ["-ra", "-rA"]) +def test_extra_test_summary_for_reruns_with_reportchars_all(testdir, report_flag): + testdir.makepyfile( + f""" + def test_pass(): + {temporary_failure()}""" + ) + result = testdir.runpytest("--reruns", "1", report_flag) + result.stdout.fnmatch_lines_random(["RERUN test_*:*"]) + assert "rerun test summary info" in result.stdout.str() + assert "1 rerun" in result.stdout.str() + + def test_rerun_show_tracebacks_for_eventual_pass(testdir): testdir.makepyfile( f"""