-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Make xpass failure again #11498
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
Closed
TanyaAgarwal28
wants to merge
10
commits into
pytest-dev:main
from
TanyaAgarwal28:make-xpass-failure-again
Closed
Make xpass failure again #11498
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
54b074b
Bug Fix 11456: Duplicated parameters in @pytest.mark.parametrize
TanyaAgarwal28 c526594
Merge branch 'pytest-dev:main' into main
TanyaAgarwal28 115fb0d
Make xpass a failure again #11467
TanyaAgarwal28 c154612
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 78b50ea
Make xpass a failure again #11467
TanyaAgarwal28 7595627
Merge branch 'make-xpass-failure-again' of https://github.com/TanyaAg…
TanyaAgarwal28 449ce35
Make xpass a failure again #11467
TanyaAgarwal28 fd6dd2a
Make xpass a failure again #11467
TanyaAgarwal28 0a82add
Make xpass a failure again #11467
TanyaAgarwal28 6f5ad57
Make xpass a failure again #11467
TanyaAgarwal28 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
In this strict parameter of xfail is set to true by default and it will ensure xpass is either a warning or a failure in any case. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,6 @@ | |
from _pytest.outcomes import skip | ||
from _pytest.outcomes import xfail | ||
from _pytest.reports import BaseReport | ||
from _pytest.reports import TestReport | ||
from _pytest.runner import CallInfo | ||
from _pytest.stash import StashKey | ||
|
||
|
@@ -208,7 +207,7 @@ def evaluate_xfail_marks(item: Item) -> Optional[Xfail]: | |
"""Evaluate xfail marks on item, returning Xfail if triggered.""" | ||
for mark in item.iter_markers(name="xfail"): | ||
run = mark.kwargs.get("run", True) | ||
strict = mark.kwargs.get("strict", item.config.getini("xfail_strict")) | ||
strict = mark.kwargs.get(item.config.getini("xfail_strict"), True) | ||
raises = mark.kwargs.get("raises", None) | ||
if "condition" not in mark.kwargs: | ||
conditions = mark.args | ||
|
@@ -244,7 +243,7 @@ def pytest_runtest_setup(item: Item) -> None: | |
xfail("[NOTRUN] " + xfailed.reason) | ||
|
||
|
||
@hookimpl(wrapper=True) | ||
@hookimpl(hookwrapper=True) | ||
def pytest_runtest_call(item: Item) -> Generator[None, None, None]: | ||
xfailed = item.stash.get(xfailed_key, None) | ||
if xfailed is None: | ||
|
@@ -253,20 +252,18 @@ def pytest_runtest_call(item: Item) -> Generator[None, None, None]: | |
if xfailed and not item.config.option.runxfail and not xfailed.run: | ||
xfail("[NOTRUN] " + xfailed.reason) | ||
|
||
try: | ||
return (yield) | ||
finally: | ||
# The test run may have added an xfail mark dynamically. | ||
xfailed = item.stash.get(xfailed_key, None) | ||
if xfailed is None: | ||
item.stash[xfailed_key] = xfailed = evaluate_xfail_marks(item) | ||
yield | ||
|
||
# The test run may have added an xfail mark dynamically. | ||
xfailed = item.stash.get(xfailed_key, None) | ||
if xfailed is None: | ||
item.stash[xfailed_key] = xfailed = evaluate_xfail_marks(item) | ||
|
||
|
||
@hookimpl(wrapper=True) | ||
def pytest_runtest_makereport( | ||
item: Item, call: CallInfo[None] | ||
) -> Generator[None, TestReport, TestReport]: | ||
rep = yield | ||
@hookimpl(hookwrapper=True) | ||
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. please restore the prior wrapper definition as thats the new style hook wrapper declaration from pluggy |
||
def pytest_runtest_makereport(item: Item, call: CallInfo[None]): | ||
outcome = yield | ||
rep = outcome.get_result() | ||
xfailed = item.stash.get(xfailed_key, None) | ||
if item.config.option.runxfail: | ||
pass # don't interfere | ||
|
@@ -289,7 +286,6 @@ def pytest_runtest_makereport( | |
else: | ||
rep.outcome = "passed" | ||
rep.wasxfail = xfailed.reason | ||
return rep | ||
|
||
|
||
def pytest_report_teststatus(report: BaseReport) -> Optional[Tuple[str, str, str]]: | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
in order to ensure backward compatibility we cannot go straight from non-strict to strict
instead we have to start by warning if strict was not set to true or false
the warning should indicate that a future major release of pytest will change the default from False to True
and recommend to use struct=True as default and a plugin for actually flaky tests
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.
Sure