From ee88679c540f1f387e50e76de470b2fd25f1036d Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Mon, 15 Feb 2016 18:43:45 -0200 Subject: [PATCH] Fix bug in strict xfail: test was not being actually called --- CHANGELOG.rst | 3 +++ _pytest/skipping.py | 3 +++ testing/python/collect.py | 1 + testing/test_skipping.py | 3 ++- 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 15aa75306..ebb2955ca 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -17,6 +17,9 @@ ``xfail_strict`` ini option that can be used to configure it project-wise. Thanks `@rabbbit`_ for the request and `@nicoddemus`_ for the PR (`#1355`_). +* ``Parser.addini`` now supports options of type ``bool``. Thanks + `@nicoddemus`_ for the PR. + * New ``ALLOW_BYTES`` doctest option strips ``b`` prefixes from byte strings in doctest output (similar to ``ALLOW_UNICODE``). Thanks `@jaraco`_ for the request and `@nicoddemus`_ for the PR (`#1287`_). diff --git a/_pytest/skipping.py b/_pytest/skipping.py index 1b1c68267..40b465244 100644 --- a/_pytest/skipping.py +++ b/_pytest/skipping.py @@ -182,8 +182,11 @@ def pytest_runtest_setup(item): item._evalxfail = MarkEvaluator(item, 'xfail') check_xfail_no_run(item) + +@pytest.mark.hookwrapper def pytest_pyfunc_call(pyfuncitem): check_xfail_no_run(pyfuncitem) + yield evalxfail = pyfuncitem._evalxfail if evalxfail.istrue() and _is_strict_xfail(evalxfail, pyfuncitem.config): del pyfuncitem._evalxfail diff --git a/testing/python/collect.py b/testing/python/collect.py index 752cd81e3..5aad619b4 100644 --- a/testing/python/collect.py +++ b/testing/python/collect.py @@ -497,6 +497,7 @@ class TestFunction: return True config.pluginmanager.register(MyPlugin1()) config.pluginmanager.register(MyPlugin2()) + config.hook.pytest_runtest_setup(item=item) config.hook.pytest_pyfunc_call(pyfuncitem=item) def test_multiple_parametrize(self, testdir): diff --git a/testing/test_skipping.py b/testing/test_skipping.py index 8e43914f0..227177eb0 100644 --- a/testing/test_skipping.py +++ b/testing/test_skipping.py @@ -357,7 +357,7 @@ class TestXFail: @pytest.mark.xfail(reason='unsupported feature', strict=%s) def test_foo(): - pass + with open('foo_executed', 'w'): pass # make sure test executes """ % strict) result = testdir.runpytest(p, '-rxX') if strict: @@ -371,6 +371,7 @@ class TestXFail: 'XPASS test_strict_xfail.py::test_foo unsupported feature', ]) assert result.ret == (1 if strict else 0) + assert testdir.tmpdir.join('foo_executed').isfile() @pytest.mark.parametrize('strict', [True, False]) def test_strict_xfail_condition(self, testdir, strict):