Skip to content

Commit 4fc20d0

Browse files
committed
Change outcome to 'passed' for xfail unless it's strict
1 parent ffb583a commit 4fc20d0

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

_pytest/skipping.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ def pytest_runtest_makereport(item, call):
230230
if hasattr(item, '_unexpectedsuccess') and rep.when == "call":
231231
# we need to translate into how pytest encodes xpass
232232
rep.wasxfail = "reason: " + repr(item._unexpectedsuccess)
233-
rep.outcome = "failed"
233+
# TODO: Do we need to check for strict xfail here as well?
234+
rep.outcome = "passed"
234235
elif item.config.option.runxfail:
235236
pass # don't interefere
236237
elif call.excinfo and call.excinfo.errisinstance(pytest.xfail.Exception):
@@ -245,7 +246,12 @@ def pytest_runtest_makereport(item, call):
245246
rep.outcome = "skipped"
246247
rep.wasxfail = evalxfail.getexplanation()
247248
elif call.when == "call":
248-
rep.outcome = "failed" # xpass outcome
249+
strict_default = item.config.getini('xfail_strict')
250+
is_strict_xfail = evalxfail.get('strict', strict_default)
251+
if is_strict_xfail:
252+
rep.outcome = "failed"
253+
else:
254+
rep.outcome = "passed"
249255
rep.wasxfail = evalxfail.getexplanation()
250256
elif evalskip is not None and rep.skipped and type(rep.longrepr) is tuple:
251257
# skipped by mark.skipif; change the location of the failure
@@ -260,7 +266,7 @@ def pytest_report_teststatus(report):
260266
if hasattr(report, "wasxfail"):
261267
if report.skipped:
262268
return "xfailed", "x", "xfail"
263-
elif report.failed:
269+
elif report.passed:
264270
return "xpassed", "X", ("XPASS", {'yellow': True})
265271

266272
# called by the terminalreporter instance/plugin

0 commit comments

Comments
 (0)