add new pytest_handlecrashitem hook

allows handling and rescheduling crash tests

PR #651

Co-authored-by: xoviat <xoviat@users.noreply.github.com>
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
This commit is contained in:
xoviat
2021-04-27 07:07:49 -05:00
committed by GitHub
parent f5665436e9
commit f861f1667d
7 changed files with 77 additions and 0 deletions

View File

@@ -64,3 +64,20 @@ def pytest_xdist_auto_num_workers(config):
.. versionadded:: 2.1
"""
@pytest.mark.firstresult
def pytest_handlecrashitem(crashitem, report, sched):
"""
Handle a crashitem, modifying the report if necessary.
The scheduler is provided as a parameter to reschedule the test if desired with
`sched.mark_test_pending`.
def pytest_handlecrashitem(crashitem, report, sched):
if should_rerun(crashitem):
sched.mark_test_pending(crashitem)
report.outcome = "rerun"
.. versionadded:: 2.2.1
"""