Skip to content

Commit 158f3cf

Browse files
merge master
2 parents 82c74fe + 99c4b6f commit 158f3cf

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

CHANGELOG.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
* fix `#510`_: skip tests where one parameterize dimension was empty
77
thanks Alex Stapleton for the Report and `@RonnyPfannschmidt`_ for the PR
88

9+
* Fix Xfail does not work with condition keyword argument.
10+
Thanks `@astraw38`_ for reporting the issue (`#1496`_) and `@tomviner`_
11+
for PR the (`#1524`_).
12+
913
* Fix win32 path issue when puttinging custom config file with absolute path
1014
in ``pytest.main("-c your_absolute_path")``.
1115

@@ -22,8 +26,11 @@
2226

2327
.. _#510: https://github.com/pytest-dev/pytest/issues/510
2428
.. _#1506: https://github.com/pytest-dev/pytest/pull/1506
29+
.. _#1496: https://github.com/pytest-dev/pytest/issue/1496
30+
.. _#1524: https://github.com/pytest-dev/pytest/issue/1524
2531

2632
.. _@prusse-martin: https://github.com/prusse-martin
33+
.. _@astraw38: https://github.com/astraw38
2734

2835

2936
2.9.1

_pytest/skipping.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def _istrue(self):
120120
return self.result
121121
if self.holder:
122122
d = self._getglobals()
123-
if self.holder.args:
123+
if self.holder.args or 'condition' in self.holder.kwargs:
124124
self.result = False
125125
# "holder" might be a MarkInfo or a MarkDecorator; only
126126
# MarkInfo keeps track of all parameters it received in an
@@ -130,6 +130,8 @@ def _istrue(self):
130130
else:
131131
arglist = [(self.holder.args, self.holder.kwargs)]
132132
for args, kwargs in arglist:
133+
if 'condition' in kwargs:
134+
args = (kwargs['condition'],)
133135
for expr in args:
134136
self.expr = expr
135137
if isinstance(expr, py.builtin._basestring):

testing/test_skipping.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,19 @@ def test_foo():
405405
result.stdout.fnmatch_lines('*1 passed*')
406406
assert result.ret == 0
407407

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+
408421
@pytest.mark.parametrize('strict_val', ['true', 'false'])
409422
def test_strict_xfail_default_from_file(self, testdir, strict_val):
410423
testdir.makeini('''

0 commit comments

Comments
 (0)