Skip to content

Commit

Permalink
Fix reported location of skip when --runxfail is used (#7432)
Browse files Browse the repository at this point in the history
Co-authored-by: Arvin Firouzi <427014@student.fontys.nl>
  • Loading branch information
AFirouzi and Arvin Firouzi committed Jul 9, 2020
1 parent 678c1a0 commit c3e2b11
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog/7392.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix the reported location of tests skipped with ``@pytest.mark.skip`` when ``--runxfail`` is used.
3 changes: 2 additions & 1 deletion src/_pytest/skipping.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,8 @@ def pytest_runtest_makereport(item: Item, call: CallInfo[None]):
else:
rep.outcome = "passed"
rep.wasxfail = xfailed.reason
elif (

if (
item._store.get(skipped_by_mark_key, True)
and rep.skipped
and type(rep.longrepr) is tuple
Expand Down
25 changes: 25 additions & 0 deletions testing/test_skipping.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,31 @@ def test_func2():
["*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):
item = testdir.getitem(
"""
Expand Down

0 comments on commit c3e2b11

Please sign in to comment.