Search code examples
djangodjango-testing

How to call ipdb when a test fails in django testing?


I would like to start ipdb every time a test fails. I tried

$ ipython manage.py test myapp --pdb

but doesn't works.


Solution

  • If you pip install ipdbplugin and pip install django-nose, then add django_nose to your INSTALLED_APPS and set TEST_RUNNER = 'django_nose.NoseTestSuiteRunner', you can then call:

    ./manage.py test --ipdb
    

    or

    ./manage.py test --ipdb-failures
    

    See https://github.com/flavioamieiro/nose-ipdb and https://github.com/django-nose/django-nose for further details.