Fix reported location of skip when --runxfail is used (#7432)
Co-authored-by: Arvin Firouzi <427014@student.fontys.nl>
This commit is contained in:
parent
678c1a0745
commit
c3e2b11a62
|
@ -0,0 +1 @@
|
||||||
|
Fix the reported location of tests skipped with ``@pytest.mark.skip`` when ``--runxfail`` is used.
|
|
@ -291,7 +291,8 @@ def pytest_runtest_makereport(item: Item, call: CallInfo[None]):
|
||||||
else:
|
else:
|
||||||
rep.outcome = "passed"
|
rep.outcome = "passed"
|
||||||
rep.wasxfail = xfailed.reason
|
rep.wasxfail = xfailed.reason
|
||||||
elif (
|
|
||||||
|
if (
|
||||||
item._store.get(skipped_by_mark_key, True)
|
item._store.get(skipped_by_mark_key, True)
|
||||||
and rep.skipped
|
and rep.skipped
|
||||||
and type(rep.longrepr) is tuple
|
and type(rep.longrepr) is tuple
|
||||||
|
|
|
@ -235,6 +235,31 @@ class TestXFail:
|
||||||
["*def test_func():*", "*assert 0*", "*1 failed*1 pass*"]
|
["*def test_func():*", "*assert 0*", "*1 failed*1 pass*"]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"test_input,expected",
|
||||||
|
[
|
||||||
|
(
|
||||||
|
["-rs"],
|
||||||
|
["SKIPPED [1] test_sample.py:2: unconditional skip", "*1 skipped*"],
|
||||||
|
),
|
||||||
|
(
|
||||||
|
["-rs", "--runxfail"],
|
||||||
|
["SKIPPED [1] test_sample.py:2: unconditional skip", "*1 skipped*"],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_xfail_run_with_skip_mark(self, testdir, test_input, expected):
|
||||||
|
testdir.makepyfile(
|
||||||
|
test_sample="""
|
||||||
|
import pytest
|
||||||
|
@pytest.mark.skip
|
||||||
|
def test_skip_location() -> None:
|
||||||
|
assert 0
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
result = testdir.runpytest(*test_input)
|
||||||
|
result.stdout.fnmatch_lines(expected)
|
||||||
|
|
||||||
def test_xfail_evalfalse_but_fails(self, testdir):
|
def test_xfail_evalfalse_but_fails(self, testdir):
|
||||||
item = testdir.getitem(
|
item = testdir.getitem(
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue