Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 6 commits into from
Jul 9, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 issue not ignoring --runxfail when using skip mark in a test.
bluetech marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion src/_pytest/skipping.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def pytest_runtest_makereport(item: Item, call: CallInfo[None]):
else:
rep.longrepr = "Unexpected success"
rep.outcome = "failed"
elif item.config.option.runxfail:
elif item.config.option.runxfail and xfailed:
pass # don't interfere
elif call.excinfo and isinstance(call.excinfo.value, xfail.Exception):
assert call.excinfo.value.msg is not None
Expand Down
14 changes: 14 additions & 0 deletions testing/test_skipping.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,20 @@ def test_func2():
["*def test_func():*", "*assert 0*", "*1 failed*1 pass*"]
)

def test_xfail_run_with_skip_mark(self, testdir):
gnikonorov marked this conversation as resolved.
Show resolved Hide resolved
p = testdir.makepyfile(
"""
import pytest
@pytest.mark.skip
def test_skip_location() -> None:
assert 0
"""
)
result = testdir.runpytest(p, "-rs")
result.stdout.fnmatch_lines(["*unconditional skip*", "*1 skipped*"])
result = testdir.runpytest(p, "-rs --runxfail")
result.stdout.fnmatch_lines(["*unconditional skip*", "*1 skipped*"])

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