diff --git a/README.rst b/README.rst index 2ff8820..fca059a 100644 --- a/README.rst +++ b/README.rst @@ -366,6 +366,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 `pytest-forked `_: both plugins 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 4700874..13eb824 100644 --- a/tests/test_pytest_rerunfailures.py +++ b/tests/test_pytest_rerunfailures.py @@ -617,6 +617,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_flaky_marker_with_zero_reruns_disables_rerun(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.*