Fix reported location of skip when --runxfail is used (#7432)

Co-authored-by: Arvin Firouzi <427014@student.fontys.nl>
This commit is contained in:
Arvin Firouzi 2020-07-09 22:10:32 +02:00 committed by GitHub
parent 678c1a0745
commit c3e2b11a62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 1 deletions

View File

@ -0,0 +1 @@
Fix the reported location of tests skipped with ``@pytest.mark.skip`` when ``--runxfail`` is used.

View File

@ -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

View File

@ -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(
""" """