From e25c78b00ad36c96b864dde2fef73a16e76482db Mon Sep 17 00:00:00 2001 From: Thomas LEVEIL Date: Tue, 21 Feb 2017 01:04:50 +0100 Subject: [PATCH] TESTS: add pytest `incremental` marker to mark tests as expected to fail if previous test failed see http://stackoverflow.com/a/12579625/107049 --- test/conftest.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/conftest.py b/test/conftest.py index fcff6ea..43f83bb 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -445,6 +445,18 @@ def pytest_runtest_logreport(report): report.longrepr.addsection('nginx-proxy conf', get_nginx_conf_from_container(container)) +# Py.test `incremental` marker, see http://stackoverflow.com/a/12579625/107049 +def pytest_runtest_makereport(item, call): + if "incremental" in item.keywords: + if call.excinfo is not None: + parent = item.parent + parent._previousfailed = item + + +def pytest_runtest_setup(item): + previousfailed = getattr(item.parent, "_previousfailed", None) + if previousfailed is not None: + pytest.xfail("previous test failed (%s)" % previousfailed.name) ############################################################################### #