issue 1496 - xfail with condition keyword
This commit is contained in:
parent
6a3c943ce2
commit
99c4b6fdc3
|
@ -3,7 +3,9 @@
|
||||||
|
|
||||||
**Bug Fixes**
|
**Bug Fixes**
|
||||||
|
|
||||||
*
|
* Fix Xfail does not work with condition keyword argument.
|
||||||
|
Thanks `@astraw38`_ for reporting the issue (`#1496`_) and `@tomviner`_
|
||||||
|
for PR the (`#1524`_).
|
||||||
|
|
||||||
*
|
*
|
||||||
|
|
||||||
|
@ -20,8 +22,11 @@
|
||||||
|
|
||||||
|
|
||||||
.. _#1506: https://github.com/pytest-dev/pytest/pull/1506
|
.. _#1506: https://github.com/pytest-dev/pytest/pull/1506
|
||||||
|
.. _#1496: https://github.com/pytest-dev/pytest/issue/1496
|
||||||
|
.. _#1524: https://github.com/pytest-dev/pytest/issue/1524
|
||||||
|
|
||||||
.. _@prusse-martin: https://github.com/prusse-martin
|
.. _@prusse-martin: https://github.com/prusse-martin
|
||||||
|
.. _@astraw38: https://github.com/astraw38
|
||||||
|
|
||||||
|
|
||||||
2.9.1
|
2.9.1
|
||||||
|
|
|
@ -120,7 +120,7 @@ class MarkEvaluator:
|
||||||
return self.result
|
return self.result
|
||||||
if self.holder:
|
if self.holder:
|
||||||
d = self._getglobals()
|
d = self._getglobals()
|
||||||
if self.holder.args:
|
if self.holder.args or 'condition' in self.holder.kwargs:
|
||||||
self.result = False
|
self.result = False
|
||||||
# "holder" might be a MarkInfo or a MarkDecorator; only
|
# "holder" might be a MarkInfo or a MarkDecorator; only
|
||||||
# MarkInfo keeps track of all parameters it received in an
|
# MarkInfo keeps track of all parameters it received in an
|
||||||
|
@ -130,6 +130,8 @@ class MarkEvaluator:
|
||||||
else:
|
else:
|
||||||
arglist = [(self.holder.args, self.holder.kwargs)]
|
arglist = [(self.holder.args, self.holder.kwargs)]
|
||||||
for args, kwargs in arglist:
|
for args, kwargs in arglist:
|
||||||
|
if 'condition' in kwargs:
|
||||||
|
args = (kwargs['condition'],)
|
||||||
for expr in args:
|
for expr in args:
|
||||||
self.expr = expr
|
self.expr = expr
|
||||||
if isinstance(expr, py.builtin._basestring):
|
if isinstance(expr, py.builtin._basestring):
|
||||||
|
|
|
@ -405,6 +405,19 @@ class TestXFail:
|
||||||
result.stdout.fnmatch_lines('*1 passed*')
|
result.stdout.fnmatch_lines('*1 passed*')
|
||||||
assert result.ret == 0
|
assert result.ret == 0
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('strict', [True, False])
|
||||||
|
def test_xfail_condition_keyword(self, testdir, strict):
|
||||||
|
p = testdir.makepyfile("""
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
@pytest.mark.xfail(condition=False, reason='unsupported feature', strict=%s)
|
||||||
|
def test_foo():
|
||||||
|
pass
|
||||||
|
""" % strict)
|
||||||
|
result = testdir.runpytest(p, '-rxX')
|
||||||
|
result.stdout.fnmatch_lines('*1 passed*')
|
||||||
|
assert result.ret == 0
|
||||||
|
|
||||||
@pytest.mark.parametrize('strict_val', ['true', 'false'])
|
@pytest.mark.parametrize('strict_val', ['true', 'false'])
|
||||||
def test_strict_xfail_default_from_file(self, testdir, strict_val):
|
def test_strict_xfail_default_from_file(self, testdir, strict_val):
|
||||||
testdir.makeini('''
|
testdir.makeini('''
|
||||||
|
|
Loading…
Reference in New Issue