-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Labels
type: enhancementnew feature or API change, should be merged into features branchnew feature or API change, should be merged into features branch
Description
When using -x / --maxfail the Interrupted exception is thrown, and gets handled in the same place as KeyboardInterrupt (
Lines 99 to 106 in 86ec3f3
| except KeyboardInterrupt: | |
| excinfo = _pytest._code.ExceptionInfo() | |
| if initstate < 2 and isinstance( | |
| excinfo.value, pytest.exit.Exception): | |
| sys.stderr.write('{0}: {1}\n'.format( | |
| excinfo.typename, excinfo.value.msg)) | |
| config.hook.pytest_keyboard_interrupt(excinfo=excinfo) | |
| session.exitstatus = EXIT_INTERRUPTED |
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?
Metadata
Metadata
Assignees
Labels
type: enhancementnew feature or API change, should be merged into features branchnew feature or API change, should be merged into features branch