From e3f4f19b41a26c501d742b7ee407681b79b5eb98 Mon Sep 17 00:00:00 2001 From: Louis Deconinck Date: Thu, 17 Sep 2026 21:35:24 +0200 Subject: [PATCH] Add pytest-reportlog integration test and document compatibility Rerun attempts are already published through pytest_runtest_logreport, so pytest-reportlog emits a TestReport per attempt with outcome "rerun" and a rerun counter. Pin that with a test, add pytest-reportlog to the tox test deps, and note the compatibility in the README. Closes #134. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- README.rst | 4 ++++ changes/134.misc.rst | 3 +++ tests/test_pytest_rerunfailures.py | 23 +++++++++++++++++++++++ tox.ini | 1 + 4 files changed, 31 insertions(+) create mode 100644 changes/134.misc.rst diff --git a/README.rst b/README.rst index 747072e..5862278 100644 --- a/README.rst +++ b/README.rst @@ -352,6 +352,10 @@ be marked as failed. Compatibility ------------- +* This plugin is compatible with + `pytest-reportlog `_: each + attempt is emitted as a ``TestReport``, with retried failures using the + ``"rerun"`` outcome. * This plugin is *not* compatible with pytest-xdist's --looponfail flag. * This plugin is *not* compatible with the core --pdb flag. * This plugin is *not* compatible with the plugin diff --git a/changes/134.misc.rst b/changes/134.misc.rst new file mode 100644 index 0000000..43813c0 --- /dev/null +++ b/changes/134.misc.rst @@ -0,0 +1,3 @@ +Add an integration test covering ``pytest-reportlog`` compatibility: each +attempt is emitted as a ``TestReport``, with retried failures using the +``"rerun"`` outcome. diff --git a/tests/test_pytest_rerunfailures.py b/tests/test_pytest_rerunfailures.py index a4208c5..91d52cb 100644 --- a/tests/test_pytest_rerunfailures.py +++ b/tests/test_pytest_rerunfailures.py @@ -548,6 +548,29 @@ def test_pass(): assert_outcomes(result, passed=1, rerun=2) +def test_reportlog_contains_rerun_reports(testdir): + pytest.importorskip("pytest_reportlog") + testdir.makepyfile( + f""" + def test_pass(): + {temporary_failure()}""" + ) + result = testdir.runpytest("--reruns", "1", "--report-log=log.jsonl") + assert_outcomes(result, passed=1, rerun=1) + + import json + + reports = [ + json.loads(line) + for line in testdir.tmpdir.join("log.jsonl").read().splitlines() + if line.strip() + ] + test_reports = [r for r in reports if r.get("$report_type") == "TestReport"] + call_reports = [r for r in test_reports if r.get("when") == "call"] + assert [r["outcome"] for r in call_reports] == ["rerun", "passed"] + assert [r["rerun"] for r in call_reports] == [0, 1] + + def test_no_extra_test_summary_for_reruns_by_default(testdir): testdir.makepyfile( f""" diff --git a/tox.ini b/tox.ini index b069bbe..a510037 100644 --- a/tox.ini +++ b/tox.ini @@ -21,6 +21,7 @@ minversion = 4.0 commands = pytest tests/ {posargs} deps = xdist: pytest-xdist + pytest-reportlog pytest82: pytest==8.2.* pytest83: pytest==8.3.* pytest84: pytest==8.4.*