From d183ebdce08bc95d0d980a794e036951f3ff2604 Mon Sep 17 00:00:00 2001 From: Louis Deconinck Date: Thu, 17 Sep 2026 21:23:42 +0200 Subject: [PATCH 1/2] 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""" From 34f42031ac4ae3535042d8f0ed460f4e8216d84b Mon Sep 17 00:00:00 2001 From: Michael Howitz Date: Tue, 6 Oct 2026 08:46:14 +0200 Subject: [PATCH 2/2] Honour -rN reset when deciding to show the rerun summary Co-Authored-By: Claude --- src/pytest_rerunfailures.py | 5 +++-- tests/test_pytest_rerunfailures.py | 11 +++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/pytest_rerunfailures.py b/src/pytest_rerunfailures.py index 76e4e5a0..db3974ac 100644 --- a/src/pytest_rerunfailures.py +++ b/src/pytest_rerunfailures.py @@ -1377,8 +1377,9 @@ def pytest_terminal_summary(terminalreporter): show_tracebacks = tr.config.getoption("rerun_show_tracebacks", False) # -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 + # 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): return diff --git a/tests/test_pytest_rerunfailures.py b/tests/test_pytest_rerunfailures.py index fa4a99a2..20944483 100644 --- a/tests/test_pytest_rerunfailures.py +++ b/tests/test_pytest_rerunfailures.py @@ -811,6 +811,17 @@ def test_pass(): assert "1 rerun" in result.stdout.str() +def test_no_extra_test_summary_for_reruns_with_reportchars_reset(testdir): + testdir.makepyfile( + f""" + def test_pass(): + {temporary_failure()}""" + ) + result = testdir.runpytest("--reruns", "1", "-raN") + assert "rerun test summary info" not in result.stdout.str() + assert "1 rerun" in result.stdout.str() + + def test_rerun_show_tracebacks_for_eventual_pass(testdir): testdir.makepyfile( f"""