pytest-pudb
pytest-pudb copied to clipboard
Support pudb external breakpoint file
Load pudb external breakpoints file if --pudb parameter used.
How is this done?
Sorry, not yet. But I'll be happy to merge a PR for this feature.
Any hints on how can I do that? (not the PR, but how should this be approached like where these files usually are when using pudb, whats their format.. you know couple of links to start digging)
For sure. There are 2 main classes you need to work with: PuDB Debugger and it's base Bdb from python's library.
- Bdb has a method
set_break()that sets breakpoint on the particular line. - PuDB has some code to parse external breakpoints file (
load_breakpoints()function that is called at PuDB debugger initialisation). - Note, that running all code under the tracing hook will kill the execution performance. So there is a method
Bdb.set_continue()that sets tracing hook only if there are breakpoints set. PuDB.set_trace()takes an optional parameterpause, that indicates whether debugger must stop at the current line or continue work, without stopping.- Pytest has plugin hooks that we can stick to to start our code under debugger.
I think that the best solution would be to add some cmd parameter, that will mean two things:
- We need to parse breakpoints from the external file (I'd prefer pointing this file via that parameter than forcing user to put that file in the
XDG_CONFIG_DIRSpath that PuDB does). - We need to start debugger tracing hook at the beginning of our tests run via pytest hook.
Found this thread while looking for a similar but slightly different usecase. I believe that this issue is a prerequisite for the feature I'm looking for - but please let me know if I am mistaken.
It would be incredibly helpful for pytest-pudb to support pdb run style restarts with pytest --pudb created breakpoints. Specifically, when writing tests for an application it is rarely the test code that is in error, rather a supporting function that has already been invoked before the failing assertion. I don't believe that it is possible to backstep, but pudb does support easy jumps through the stacktrace via m that allow breakpoint creation at the suspected point of failure.
This would be very useful for me.
Is there any new development regarding the loading of external pudb breakpoints? I would be interested to get involved.