diff --git a/changelog/206.feature b/changelog/206.feature new file mode 100644 index 0000000..90296b3 --- /dev/null +++ b/changelog/206.feature @@ -0,0 +1,2 @@ +``xdist`` now supports tests to log results multiple times, improving integration with plugins which require +it like `pytest-rerunfailures _`. diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index 0fe3576..42345d7 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -502,6 +502,32 @@ def test_crashing_item(testdir, when): ]) +def test_multiple_log_reports(testdir): + """ + Ensure that pytest-xdist supports plugins that emit multiple logreports + (#206). + Inspired by pytest-rerunfailures. + """ + testdir.makeconftest(""" + from _pytest.runner import runtestprotocol + def pytest_runtest_protocol(item, nextitem): + item.ihook.pytest_runtest_logstart(nodeid=item.nodeid, + location=item.location) + reports = runtestprotocol(item, nextitem=nextitem) + for report in reports: + item.ihook.pytest_runtest_logreport(report=report) + return True + """) + testdir.makepyfile(""" + def test(): + pass + """) + result = testdir.runpytest("-n1") + result.stdout.fnmatch_lines([ + "*2 passed*", + ]) + + def test_skipping(testdir): p = testdir.makepyfile(""" import pytest