Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changes/45.feature.rst
Original file line number Diff line number Diff line change
@@ -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``.
7 changes: 6 additions & 1 deletion src/pytest_rerunfailures.py
Original file line number Diff line number Diff line change
Expand Up @@ -1375,7 +1375,12 @@ 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 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 thread
icemac marked this conversation as resolved.
return

lines = show_rerun(terminalreporter, show_tracebacks=show_tracebacks)
Expand Down
24 changes: 24 additions & 0 deletions tests/test_pytest_rerunfailures.py
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,30 @@ 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_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"""
Expand Down
Loading