executing python unittest with ipdb

308 views Asked by At

Typically I run my python unit test with:

python -m unittest test.<module-name>

I would like to debug my tests using ipdb but I cannot figure out how to invoke theunittest module in manner similar to the command above.

The directory structure is:

  • base/src for the source code
  • base/test for the test code

Tests run from the base directory.

The preference is to 'run' & 'debug' test cases in the same manner, specifically the preference is to debug with ipdb in a similar manner to the python command above.

FYI

Interpreter is python2

1

There are 1 answers

0
barrios On

I don't know how to do this with the unittest module from the standardlib, but the testrunner pytest has at least pdb (not ipdb) support. Just invoke it with

pytest --pdb

and it drops into pdb with the first failure.