-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Handle xfail(strict=True) properly in --step-wise mode #5555
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
``--step-wise`` now handles ``xfail(strict=True)`` markers properly. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -165,3 +165,56 @@ def test_stop_on_collection_errors(broken_testdir, broken_first): | |
files.reverse() | ||
result = broken_testdir.runpytest("-v", "--strict-markers", "--stepwise", *files) | ||
result.stdout.fnmatch_lines("*errors during collection*") | ||
|
||
|
||
def test_xfail_handling(testdir): | ||
"""Ensure normal xfail is ignored, and strict xfail interrupts the session in sw mode | ||
|
||
(#5547) | ||
""" | ||
contents = """ | ||
import pytest | ||
def test_a(): pass | ||
|
||
@pytest.mark.xfail(strict={strict}) | ||
def test_b(): assert {assert_value} | ||
|
||
def test_c(): pass | ||
def test_d(): pass | ||
""" | ||
testdir.makepyfile(contents.format(assert_value="0", strict="False")) | ||
result = testdir.runpytest("--sw", "-v") | ||
result.stdout.fnmatch_lines( | ||
[ | ||
"*::test_a PASSED *", | ||
"*::test_b XFAIL *", | ||
"*::test_c PASSED *", | ||
"*::test_d PASSED *", | ||
"* 3 passed, 1 xfailed in *", | ||
] | ||
) | ||
|
||
testdir.makepyfile(contents.format(assert_value="1", strict="True")) | ||
result = testdir.runpytest("--sw", "-v") | ||
result.stdout.fnmatch_lines( | ||
[ | ||
"*::test_a PASSED *", | ||
"*::test_b FAILED *", | ||
"* Interrupted*", | ||
"* 1 failed, 1 passed in *", | ||
] | ||
) | ||
|
||
# because we are writing to the same file, mtime might not be affected enough to | ||
# invalidate the cache, making this next run flaky | ||
testdir.tmpdir.join("__pycache__").remove() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. argh! Should we remove all There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ufff that's pretty unfortunate. Probably not though, the assert rewrite tests I think need that Another idea would be to use utime to force the issue in another way There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well in that case it doesn't really matter, so let's stick with just removing the |
||
testdir.makepyfile(contents.format(assert_value="0", strict="True")) | ||
result = testdir.runpytest("--sw", "-v") | ||
result.stdout.fnmatch_lines( | ||
[ | ||
"*::test_b XFAIL *", | ||
"*::test_c PASSED *", | ||
"*::test_d PASSED *", | ||
"* 2 passed, 1 deselected, 1 xfailed in *", | ||
] | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment seems wrong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops indeed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#5560