Skip to content

Commit 018197d

Browse files
committed
Fix broken test in test_skipping and add one for strict xfail
1 parent ea379e0 commit 018197d

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

testing/test_skipping.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,15 +145,29 @@ def test_func():
145145
def test_xfail_xpassed(self, testdir):
146146
item = testdir.getitem("""
147147
import pytest
148-
@pytest.mark.xfail
148+
@pytest.mark.xfail(reason="nope")
149+
def test_func():
150+
assert 1
151+
""")
152+
reports = runtestprotocol(item, log=False)
153+
assert len(reports) == 3
154+
callreport = reports[1]
155+
assert callreport.passed
156+
assert callreport.wasxfail == "nope"
157+
158+
def test_xfail_xpassed_strict(self, testdir):
159+
item = testdir.getitem("""
160+
import pytest
161+
@pytest.mark.xfail(strict=True, reason="nope")
149162
def test_func():
150163
assert 1
151164
""")
152165
reports = runtestprotocol(item, log=False)
153166
assert len(reports) == 3
154167
callreport = reports[1]
155168
assert callreport.failed
156-
assert callreport.wasxfail == ""
169+
assert callreport.longrepr == "[XPASS(strict)] nope"
170+
assert not hasattr(callreport, "wasxfail")
157171

158172
def test_xfail_run_anyway(self, testdir):
159173
testdir.makepyfile("""

0 commit comments

Comments
 (0)