pytest-dev / pytest-dev/pytest
pytest_keyboard_interrupt called on collection error
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 14.5k
- Forks
- 3.4k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 35
Description
Discussed in https://github.com/pytest-dev/pytest/discussions/11199
Originally posted by eleanorjboyd July 11, 2023
Quick question on pytest_keyboard_interrupt. When I use a pytest plugin and the tests I am running my plugin on have a ModuleNotFoundError my plugin calls both the pytest_exception_interact hook and then the pytest_keyboard_interrupt hook. Why is pytest_keyboard_interrupt called for a ModuleNotFoundError? Is there any way to make it so it hits only one of the exception hooks? I am trying to keep track of the number of errors hit during discovery and a single error triggering two error hooks is making that more complicated. Also open to suggestions regarding another work-around. Thanks!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the pytest_exception_interact and pytest_keyboard_interrupt hooks described in issue #11200 and the linked discussion #11199. Reproduce a collection-time ModuleNotFoundError while using a plugin, then trace why both hooks run. Done means the expected hook behavior is established and covered by an appropriate regression test or documented resolution.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100