pytest-dev / pytest-dev/pytest
Showing stack traces on KeyboardInterrupt
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 14.5k
- Forks
- 3.4k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 35
Description
Right now, the default behavior of pytest when you keyboard interrupt it is to hide the traceback, and print a message saying that you can show it with --full-trace.
I would like to suggest that it should instead always show the full traceback by default. Sometimes a test will randomly get stuck in an infinite loop. My only hope of debugging it is if I interrupt and see a traceback. I can't always rely on being able to reproduce it, so I can't just "rerun the test with --full-trace". The best I can do is to put --full-trace in my pytest.ini as a flag that is always enabled, but
- I have to do this for every project (and can't really for those I don't control)
--full-tracealso makes tracebacks extremely verbose even for normal test failures. So this is the price I have to pay to be able to see tracebacks.
I would suggest that at the very least, keyboard interrupts should have their own dedicated flag, instead of only being controlled by --full-trace. And I would highly suggest that the default of that flag should be to show the tracebacks, not to hide them, so that the user has to opt out of seeing them (not that I particularly understand why you would ever want to do that).
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 by reproducing a KeyboardInterrupt with and without --full-trace, and review how pytest.ini currently enables that option. Inspect the existing interrupt-handling tests and determine the intended behavior for a dedicated flag; done means the chosen default and opt-out behavior are covered by tests without changing normal failure traceback verbosity.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli, testing-qa
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100