diff --git a/changes/45.feature.rst b/changes/45.feature.rst new file mode 100644 index 0000000..3c0be12 --- /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 c2103fd..76e4e5a 100644 --- a/src/pytest_rerunfailures.py +++ b/src/pytest_rerunfailures.py @@ -1375,7 +1375,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 4700874..fa4a99a 100644 --- a/tests/test_pytest_rerunfailures.py +++ b/tests/test_pytest_rerunfailures.py @@ -798,6 +798,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"""