-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Derive outcomes.exit.Exit from SystemExit instead of KeyboardInterrupt #4292
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
Merged
Merged
Changes from all commits
Commits
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 @@ | ||
``pytest.outcomes.Exit`` is derived from ``SystemExit`` instead of ``KeyboardInterrupt``. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
from .reports import CollectReport | ||
from .reports import TestReport | ||
from _pytest._code.code import ExceptionInfo | ||
from _pytest.outcomes import Exit | ||
from _pytest.outcomes import skip | ||
from _pytest.outcomes import Skipped | ||
from _pytest.outcomes import TEST_OUTCOME | ||
|
@@ -190,10 +191,11 @@ def check_interactive_exception(call, report): | |
def call_runtest_hook(item, when, **kwds): | ||
hookname = "pytest_runtest_" + when | ||
ihook = getattr(item.ihook, hookname) | ||
reraise = (Exit,) | ||
if not item.config.getvalue("usepdb"): | ||
reraise += (KeyboardInterrupt,) | ||
return CallInfo.from_call( | ||
lambda: ihook(item=item, **kwds), | ||
when=when, | ||
reraise=KeyboardInterrupt if not item.config.getvalue("usepdb") else (), | ||
lambda: ihook(item=item, **kwds), when=when, reraise=reraise | ||
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. Worth a 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. IMHO that's fine 😁 |
||
) | ||
|
||
|
||
|
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.
this implies that this is a breaking change for externals
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.
What do you suggest?
Should we have a custom exception that is still derived from KeyboardInterrupt (if possible)?
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.
@blueyed its not clear to me off hand, i wonder if having multiple base classes is acceptable while preparing for a breaking release (i dont see a way to deal out warnings about this one tho)
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.
Ok.
I've just noticed that also deriving from KeyboardInterrupt goes against what this tries to do: pdb not catching pytest's Exit.
I think it is OK for a feature release, and plugins should really catch/handle
Exit
in the first place already.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.
Related btw:
pytest/src/_pytest/main.py
Line 380 in fc4aa27
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.
I think so too. I don't think this will bring problems to anyone TBH.
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.
@nicoddemus
Approve it then maybe?
(I am waiting for this for more than a month already for #4280)