-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
pytest_keyboard_interrupt hook is also called with --maxfail #1865
Comments
FWIW, |
When using `-x` to abort the test run on the first failure, pytest-testmon would previously not store the collected data: the `pytest_keyboard_interrupt` hook that is used for this gets also called for pytest's internal `Interrupted` exception, which is a subclass of `KeyboardInterrupt` (pytest-dev/pytest#1865). This patch changes it to use the result in the `pytest_runtest_protocol` method to check for `KeyboardInterrupt` there explicitly. This makes the `pytest_keyboard_interrupt` obsolete, but I've left it with some asserts for now.
I agree. I think that we should:
This has to be done carefully, because there are a number of places which handle I also noticed that |
If you do |
Good point! |
…errupt This is required for properly getting out of pdb, where KeyboardInterrupt is caught in py36 at least. Ref: pytest-dev#1865 (comment)
…errupt This is required for properly getting out of pdb, where KeyboardInterrupt is caught in py36 at least. Ref: pytest-dev#1865 (comment)
…errupt This is required for properly getting out of pdb, where KeyboardInterrupt is caught in py36 at least. Ref: pytest-dev#1865 (comment)
…errupt This is required for properly getting out of pdb, where KeyboardInterrupt is caught in py36 at least. Ref: pytest-dev#1865 (comment)
…errupt This is required for properly getting out of pdb, where KeyboardInterrupt is caught in py36 at least. Ref: pytest-dev#1865 (comment)
When using
-x
/--maxfail
the Interrupted exception is thrown, and gets handled in the same place asKeyboardInterrupt
(pytest/_pytest/main.py
Lines 99 to 106 in 86ec3f3
Therefore I think the hook name is confusing / misleading.
If this behavior is intentional, it should get added to the documentation at least.
I have noticed this, because pytest-testmon uses this hook to not save its data: https://github.com/tarpas/pytest-testmon/blob/55c89bb3df65c94e226ead8dd465f3dd5bb8927b/testmon/pytest_testmon.py#L173-L174
Here a check using
excinfo.typename
could be added to handle 'Interrupted' different from 'KeyboardInterrupt'.btw: is there a way to import the
Interrupted
class from pytest?The text was updated successfully, but these errors were encountered: