pytest-pudb icon indicating copy to clipboard operation
pytest-pudb copied to clipboard

Support pudb external breakpoint file

Open wronglink opened this issue 9 years ago • 7 comments

Load pudb external breakpoints file if --pudb parameter used.

wronglink avatar Sep 28 '16 06:09 wronglink

How is this done?

massich avatar Jul 17 '17 16:07 massich

Sorry, not yet. But I'll be happy to merge a PR for this feature.

wronglink avatar Jul 19 '17 07:07 wronglink

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)

massich avatar Jul 19 '17 14:07 massich

For sure. There are 2 main classes you need to work with: PuDB Debugger and it's base Bdb from python's library.

  1. Bdb has a method set_break() that sets breakpoint on the particular line.
  2. PuDB has some code to parse external breakpoints file (load_breakpoints() function that is called at PuDB debugger initialisation).
  3. 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.
  4. PuDB.set_trace() takes an optional parameter pause, that indicates whether debugger must stop at the current line or continue work, without stopping.
  5. 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:

  1. 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_DIRS path that PuDB does).
  2. We need to start debugger tracing hook at the beginning of our tests run via pytest hook.

wronglink avatar Jul 20 '17 09:07 wronglink

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.

majuscule avatar Aug 06 '17 04:08 majuscule

This would be very useful for me.

deliciouslytyped avatar Apr 04 '20 01:04 deliciouslytyped

Is there any new development regarding the loading of external pudb breakpoints? I would be interested to get involved.

pyrrhull avatar Jul 11 '20 11:07 pyrrhull