File tree 3 files changed +25
-2
lines changed 3 files changed +25
-2
lines changed Original file line number Diff line number Diff line change 3
3
4
4
**Bug Fixes **
5
5
6
- *
6
+ * Fix Xfail does not work with condition keyword argument.
7
+ Thanks `@astraw38 `_ for reporting the issue (`#1496 `_) and `@tomviner `_
8
+ for PR the (`#1524 `_).
7
9
8
10
*
9
11
20
22
21
23
22
24
.. _#1506 : https://github.com/pytest-dev/pytest/pull/1506
25
+ .. _#1496 : https://github.com/pytest-dev/pytest/issue/1496
26
+ .. _#1524 : https://github.com/pytest-dev/pytest/issue/1524
23
27
24
28
.. _@prusse-martin : https://github.com/prusse-martin
29
+ .. _@astraw38 : https://github.com/astraw38
25
30
26
31
27
32
2.9.1
Original file line number Diff line number Diff line change 7
7
import pytest
8
8
from _pytest .mark import MarkInfo , MarkDecorator
9
9
10
+ MISSING = object ()
11
+
10
12
11
13
def pytest_addoption (parser ):
12
14
group = parser .getgroup ("general" )
@@ -120,7 +122,7 @@ def _istrue(self):
120
122
return self .result
121
123
if self .holder :
122
124
d = self ._getglobals ()
123
- if self .holder .args :
125
+ if self .holder .args or 'condition' in self . holder . kwargs :
124
126
self .result = False
125
127
# "holder" might be a MarkInfo or a MarkDecorator; only
126
128
# MarkInfo keeps track of all parameters it received in an
@@ -130,6 +132,9 @@ def _istrue(self):
130
132
else :
131
133
arglist = [(self .holder .args , self .holder .kwargs )]
132
134
for args , kwargs in arglist :
135
+ condition = kwargs .get ('condition' , MISSING )
136
+ if condition is not MISSING :
137
+ args = (condition ,)
133
138
for expr in args :
134
139
self .expr = expr
135
140
if isinstance (expr , py .builtin ._basestring ):
Original file line number Diff line number Diff line change @@ -405,6 +405,19 @@ def test_foo():
405
405
result .stdout .fnmatch_lines ('*1 passed*' )
406
406
assert result .ret == 0
407
407
408
+ @pytest .mark .parametrize ('strict' , [True , False ])
409
+ def test_xfail_condition_keyword (self , testdir , strict ):
410
+ p = testdir .makepyfile ("""
411
+ import pytest
412
+
413
+ @pytest.mark.xfail(condition=False, reason='unsupported feature', strict=%s)
414
+ def test_foo():
415
+ pass
416
+ """ % strict )
417
+ result = testdir .runpytest (p , '-rxX' )
418
+ result .stdout .fnmatch_lines ('*1 passed*' )
419
+ assert result .ret == 0
420
+
408
421
@pytest .mark .parametrize ('strict_val' , ['true' , 'false' ])
409
422
def test_strict_xfail_default_from_file (self , testdir , strict_val ):
410
423
testdir .makeini ('''
You can’t perform that action at this time.
0 commit comments