pudb
pudb copied to clipboard
Is it possible to open arbitrary python file not only suggested modules?
Open file explicitly by fullpath
Something like option of originally pdb: b pathtests/test.py:777
I don't think it's currently supported (maybe if you manually edit sys.path before opening the modules view). It should be easy to add, though, as it would just need a GUI. I'm not sure what the best GUI would be. Maybe a button in the module loader to load from a path.
I'd be happy to take a patch that allows this that has a reasonable UI.
Do modules actually have to be imported to be loaded, or is that just a side-effect of the way the current UI works?
I don't think that's required, or, if it is, it should be possible to make it not so.
My current use case:
I am running django unittests with python -m pudb.run manage.py my_test.py
So it is ok and you could walk through files line by line.
With pbd we have great option as I describe above with explicit setting of breakpoint by full file path and line number. It could be any file.
Unfortunately I can't find tests modules in list provided by m option with pudb.
Any thoughts?
I don't suppose urwid has a file browser widget. Otherwise it will just be a simple text entry box to type in the path.
https://github.com/urwid/urwid/blob/master/examples/browse.py
That's not part of the urwid library. I don't see it as worth pulling in just for this.
Hey! So I too have this issue. If I do something like debugging a pytest test run I need to wade through a ton of pytest code before my own code is loaded and is finally able to be opened by m.
Here's my proposed solution (I don't know the code internals, though):
- when you open the "Go to Line Number" (by pressing
L) you already have a UI with the full file name - just make the file path editable by pressing the up arrow
- show error dialog saying the file doesn't exist if it doesn't exist.
I'm not 100% sure if this is true, but from a glance at the source the file has to be importable. So adding the box as you suggest should be easy, but then you just need to make sure that the file that's given can be imported somehow.
What do you mean by making sure it can be imported? Because it doesn't sound trivial :-)
The idea off the top of my head is to temporarily add the file's directory to sys.path, but this won't be enough for many imports.
Also, I can tell you that found a way around this problem. I just let the program run, at the end I choose "examine" and then I have all the modules loaded, so I can find them with "m".
I wanted this feature today to debug a complex import-time interaction. m is a bit of a problem because it both shows you the source and imports the module; I want to be able to set a breakpoint without importing.