Search code examples
pythondjangodebuggingdjango-unittest

How can I get Python's unittest to not catch exceptions?


I'm working on a Django project but I think this is a pure Python unittest question.

Normally, when you run tests, exceptions will be caught by the test runner and handled accordingly.

For debugging purposes, I want to disable this behavior, i.e. so that:

python -i manage.py test

will break into the interactive Python shell on an exception, as normal.

How to do that?

EDIT: based on the answers so far, it seems like this is more of a Django-specific question than I realized!


Solution

  • You can use django-nose test runner, it works with unittest tests, and run your tests like python manage.py test -v2 --pdb. And nose will run pdb for you.