Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/_pytest/skipping.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,13 +270,15 @@ def pytest_runtest_makereport(item: Item, call: CallInfo[None]):
else:
rep.longrepr = "Unexpected success"
rep.outcome = "failed"
elif item.config.option.runxfail:
pass # don't interfere
elif call.excinfo and isinstance(call.excinfo.value, xfail.Exception):
elif (
not item.config.option.runxfail
and call.excinfo
and isinstance(call.excinfo.value, xfail.Exception)
):
assert call.excinfo.value.msg is not None
rep.wasxfail = "reason: " + call.excinfo.value.msg
rep.outcome = "skipped"
elif not rep.skipped and xfailed:
elif (not item.config.option.runxfail) and not rep.skipped and xfailed:
if call.excinfo:
raises = xfailed.raises
if raises is not None and not isinstance(call.excinfo.value, raises):
Expand Down
30 changes: 30 additions & 0 deletions testing/test_skipping.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,21 @@ def test_bar():
result = testdir.runpytest("-rs")
result.stdout.fnmatch_lines(["*for lolz*", "*1 skipped*"])

def test_skip_reports_item_location_with_runxfail(self, testdir):
testdir.makepyfile(
test_skip="""
import pytest

@pytest.mark.skip(reason="skip me")
def test_skip():
pass
"""
)
result = testdir.runpytest("-q", "-rs", "--runxfail")
result.stdout.fnmatch_lines(["*test_skip.py:*: skip me*"])
result.stdout.no_fnmatch_line("*src/_pytest/skipping.py*")
assert result.ret == 0

def test_only_skips_marked_test(self, testdir):
testdir.makepyfile(
"""
Expand Down Expand Up @@ -679,6 +694,21 @@ def test_that():
result.stdout.fnmatch_lines(["*SKIP*1*test_foo.py*platform*", "*1 skipped*"])
assert result.ret == 0

def test_skipif_reports_item_location_with_runxfail(self, testdir):
testdir.makepyfile(
test_skipif="""
import pytest

@pytest.mark.skipif(True, reason="conditional skip")
def test_skipif():
pass
"""
)
result = testdir.runpytest("-q", "-rs", "--runxfail")
result.stdout.fnmatch_lines(["*test_skipif.py:*: conditional skip*"])
result.stdout.no_fnmatch_line("*src/_pytest/skipping.py*")
assert result.ret == 0

def test_skipif_using_platform(self, testdir):
item = testdir.getitem(
"""
Expand Down