How to automatically run tests when there's any change in my project (Django)?

user1011444 picture user1011444 · Mar 1, 2013 · Viewed 12.3k times · Source

At the moment I am running python manage.py test every once in a while after I make significant changes in my django project. Is it possible to run those tests automatically whenever I change and save a file in my project? It'll be useful to detect bugs earlier (I know rails has something like this with rspec). I am using nose and django-nose. Thanks in advance.

Answer

clacke picture clacke · Jul 22, 2016

Use entr:

$ find . -name '*.py' | entr python ./manage.py test

Or, for extra credit, combine it with ack:

$ ack --python | entr python ./manage.py test

If you want it to even find new files as you add them:

$ until ack -f --python | entr -d python ./manage.py test; do sleep 1; done