mdmintz / pdbp

pdbp (Pdb+): A drop-in replacement for pdb and pdbpp. To replace "pdb", add "import pdbp" to an "__init__.py" file.
Other
75 stars 2 forks source link

Simplest way of running in pytest #61

Closed max-sixty closed 6 months ago

max-sixty commented 6 months ago

Thanks a lot for pdbp! I've already started using it lots, gradually replacing pdbpp.

Running pdbpp within pytest seems more complicated than previous alternatives, particularly in a project where we don't want to change the python code, or when recommending it to others who just want a simple command.

Currently I'm doing:

pytest --pdb --pdbcls=pdbp:Pdb --capture=tee-sys

I appreciate the sentiments behind not blindly overriding pdb, relative to pdbpp's practice. But would there be any interest in pip install pdbp[pdb], which would override pdb like pdbpp does? While your approach is purer, the pdbpp override was overall a better experience on that dimension.

mdmintz commented 6 months ago

Overriding a system library completely is a dangerous practice. The safer way in a runtime-only override. That's achieved by adding import pdbp to an __init__.py file for pdbp. That should be enough to get the same results without completely overriding the system library.

max-sixty commented 6 months ago

Overriding a system library completely is a dangerous practice. The safer way in a runtime-only override. That's achieved by adding import pdbp to an __init__.py file for pdbp.

Right. I agree with the tradeoff, and admire that you are defaulting to the conservative choice.

I guess we weigh the tax of adding that code to each non-personal project differently. There's no other tool for which I need to maintain uncommitted changes in every project, and can no longer run git commit -am...


Any thoughts on the pytest capture question?

It seems like --capture=tee-sys is discussed in, but I would note that neither pdb nor pdbpp require this — are we confident it's not possible to avoid it?

Thanks again!

mdmintz commented 6 months ago

There might be another pytest way of handling --capture=tee-sys, but it might be a question for pytest maintainers.

I do know that you can use a pytest.ini file for reusable options.

max-sixty commented 6 months ago

OK — though neither pdb nor pdbpp require that arg in pytest — so it doesn't seem like a pytest issue...

Thanks...