Using Python pudb debugger with pytest

Simply by adding the -s flag pytest will not replace stdin and stdout and debugging will be accessible, i.e. pytest -s my_file_test.py will do the trick.

In documentation provided by ambi it is also said that previously using explicitly -s was required for regular pdb too, now -s flag is implicitly used with --pdb flag.

However pytest does not implicitly support pUdb, so setting -s is needed.


An updated answer is that there is now an adapter library available to expose a --pudb tracing option similar to the --pdb one. The more general -s option remains a valid solution for manually placed breakpoints from any debugger, of course.

To use, pip install pytest-pudb then execute Pytest via py.test --pudb. Additionally, import pudb; pudb.set_trace() functionality is supported without the need for -s or --capture=no if this adapter is installed.