Fix bug in strict xfail: test was not being actually called
This commit is contained in:
parent
9af1f63ab6
commit
ee88679c54
|
@ -17,6 +17,9 @@
|
||||||
``xfail_strict`` ini option that can be used to configure it project-wise.
|
``xfail_strict`` ini option that can be used to configure it project-wise.
|
||||||
Thanks `@rabbbit`_ for the request and `@nicoddemus`_ for the PR (`#1355`_).
|
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
|
* New ``ALLOW_BYTES`` doctest option strips ``b`` prefixes from byte strings
|
||||||
in doctest output (similar to ``ALLOW_UNICODE``).
|
in doctest output (similar to ``ALLOW_UNICODE``).
|
||||||
Thanks `@jaraco`_ for the request and `@nicoddemus`_ for the PR (`#1287`_).
|
Thanks `@jaraco`_ for the request and `@nicoddemus`_ for the PR (`#1287`_).
|
||||||
|
|
|
@ -182,8 +182,11 @@ def pytest_runtest_setup(item):
|
||||||
item._evalxfail = MarkEvaluator(item, 'xfail')
|
item._evalxfail = MarkEvaluator(item, 'xfail')
|
||||||
check_xfail_no_run(item)
|
check_xfail_no_run(item)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.hookwrapper
|
||||||
def pytest_pyfunc_call(pyfuncitem):
|
def pytest_pyfunc_call(pyfuncitem):
|
||||||
check_xfail_no_run(pyfuncitem)
|
check_xfail_no_run(pyfuncitem)
|
||||||
|
yield
|
||||||
evalxfail = pyfuncitem._evalxfail
|
evalxfail = pyfuncitem._evalxfail
|
||||||
if evalxfail.istrue() and _is_strict_xfail(evalxfail, pyfuncitem.config):
|
if evalxfail.istrue() and _is_strict_xfail(evalxfail, pyfuncitem.config):
|
||||||
del pyfuncitem._evalxfail
|
del pyfuncitem._evalxfail
|
||||||
|
|
|
@ -497,6 +497,7 @@ class TestFunction:
|
||||||
return True
|
return True
|
||||||
config.pluginmanager.register(MyPlugin1())
|
config.pluginmanager.register(MyPlugin1())
|
||||||
config.pluginmanager.register(MyPlugin2())
|
config.pluginmanager.register(MyPlugin2())
|
||||||
|
config.hook.pytest_runtest_setup(item=item)
|
||||||
config.hook.pytest_pyfunc_call(pyfuncitem=item)
|
config.hook.pytest_pyfunc_call(pyfuncitem=item)
|
||||||
|
|
||||||
def test_multiple_parametrize(self, testdir):
|
def test_multiple_parametrize(self, testdir):
|
||||||
|
|
|
@ -357,7 +357,7 @@ class TestXFail:
|
||||||
|
|
||||||
@pytest.mark.xfail(reason='unsupported feature', strict=%s)
|
@pytest.mark.xfail(reason='unsupported feature', strict=%s)
|
||||||
def test_foo():
|
def test_foo():
|
||||||
pass
|
with open('foo_executed', 'w'): pass # make sure test executes
|
||||||
""" % strict)
|
""" % strict)
|
||||||
result = testdir.runpytest(p, '-rxX')
|
result = testdir.runpytest(p, '-rxX')
|
||||||
if strict:
|
if strict:
|
||||||
|
@ -371,6 +371,7 @@ class TestXFail:
|
||||||
'XPASS test_strict_xfail.py::test_foo unsupported feature',
|
'XPASS test_strict_xfail.py::test_foo unsupported feature',
|
||||||
])
|
])
|
||||||
assert result.ret == (1 if strict else 0)
|
assert result.ret == (1 if strict else 0)
|
||||||
|
assert testdir.tmpdir.join('foo_executed').isfile()
|
||||||
|
|
||||||
@pytest.mark.parametrize('strict', [True, False])
|
@pytest.mark.parametrize('strict', [True, False])
|
||||||
def test_strict_xfail_condition(self, testdir, strict):
|
def test_strict_xfail_condition(self, testdir, strict):
|
||||||
|
|
Loading…
Reference in New Issue