From c9b39e08fc478157fc14fd8a72dace40c6910de4 Mon Sep 17 00:00:00 2001 From: Roman Yurchak Date: Wed, 3 Oct 2018 16:36:45 +0200 Subject: [PATCH] Add pytest --run-xfail run option --- test/conftest.py | 3 +++ test/python_tests.txt | 7 +++---- test/test_python.py | 10 +++++++--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/test/conftest.py b/test/conftest.py index 877b501f2..74aadd474 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -24,6 +24,9 @@ try: group.addoption( '--build-dir', action="store", default=BUILD_PATH, help="Path to the build directory") + group.addoption( + '--run-xfail', action="store_true", + help="If provided, tests marked as xfail will be run") except ImportError: pytest = None diff --git a/test/python_tests.txt b/test/python_tests.txt index 2888d57ea..adfebf6a0 100644 --- a/test/python_tests.txt +++ b/test/python_tests.txt @@ -1,12 +1,11 @@ # Test modules with a failure reason after their name are either skipped # or marked as a known failure in pytest. # -# Following reason codes are skipped, whithout running them, as they lead to -# segfaults: +# Following reason codes are skipped, as they lead to segfaults: # - segfault-: segfault in the corresponding system call. # -# While the below reason codes are marked as a known failure, and are still -# executed: +# While the below reason codes are marked as a known failure. By default, they +# are also skipped. To run them, provide --run-xfail argument to pytest, # - platform-specific: This is testing something about a particular platform # that isn't relevant here # - async: relies on async diff --git a/test/test_python.py b/test/test_python.py index 7456cc665..c5ba4b191 100644 --- a/test/test_python.py +++ b/test/test_python.py @@ -352,9 +352,13 @@ def test_cpython_core(python_test, selenium, request): .format(','.join(error_flags))) if error_flags: - request.applymarker(pytest.mark.xfail( - run=False, reason='known failure with code "{}"' - .format(','.join(error_flags)))) + if request.config.option.run_xfail: + request.applymarker(pytest.mark.xfail( + run=False, reason='known failure with code "{}"' + .format(','.join(error_flags)))) + else: + pytest.xfail('known failure with code "{}"' + .format(','.join(error_flags))) selenium.load_package('test') try: