Skip to content

Showing stack traces on KeyboardInterruptΒ #7640

Open
@asmeurer

Description

@asmeurer

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-trace also 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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: reportingrelated to terminal output and user-facing messages and errorstopic: tracebacksrelated to displaying and handling of tracebackstype: enhancementnew feature or API change, should be merged into features branch

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions