Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
3610 add trace option #3647
Closes #3610 by adding the --trace option to pytest.
This option can be used to enter the debugger at the start of every test being ran.
While implementing this PR, there were a couple of things I wasn't sure how to best handle within the pytest codebase:
How to access a config value from within the pytest_pyfunc_call hook (Right now using a global variable, likely not the ideal way to implement).
Does it make sense to add the set_break option to PytestPdb.set_trace()? This doesn't seem like the right spot for it, and I'm instead thinking of moving the other logic out into another function which PytestPdb.set_trace calls before actually breaking.
Hi @jeffreyrack, thanks a lot for the PR.
The option works well, each test starts tracing into PDB as advertised. But how do I quit the debugger?
I managed to quit by killing the terminal, but that doesn't seem like a good UI. Or perhaps I am missing something?
@nicoddemus Quit/exit will quit the debugger, which will then get started again at the start of the next test.
I believe that this is consistent with the --pdb option, where quitting the debugger will continue running the tests until the next time error that causes the debugger to be entered again.
Do you have a recommendation on what might be a better a better UI that allows the user to exit entirely?
Oh, I agree with you that it is consistent. And the feature does seem useful, my only concern is that might get some users by surprise because there's no obvious way to "stop" debugging (it certainly does not feel friendly when you run that in a file with a lot of tests, I tested with
Some ideas, just throwing them around:
All in all this seems like a really nice feature, just trying to make it a little more user friendly because that was my first impression when trying it out (or again I'm missing something more obvious than killing the terminal).
re: hard to kill tests -- I've noticed the same thing when running with
The other thing is