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

后端 未结 14 1906
有刺的猬
有刺的猬 2020-12-23 19:45

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

14条回答
  •  眼角桃花
    2020-12-23 20:00

    I just tried nose-watch and it worked fantastic! install the plugin and run the test with the --with-watch option.

    Update: :( it does not seem to work well when running tests from django-nose's manage.py helper.

    Eventually I opted to use tdaemon, which supports django, although might require a bit of fiddling as well for full fledged projects.

    For example here is how I ran it for my django project:

    tdaemon -t django --custom-args=a_specific_app_to_test -d --ignore-dirs logs
    

    The --custom-args was to focus tests to specific app (same as you would do python manage.py test a_specific_app_to_test

    The -d argument is to enable debug logging, which prints which file change triggered the run.

    The --ignore-dirs was necessary because my tests wrote to the logs (which in itself is a problem!) and tdaemon went into an infinite loop.

提交回复
热议问题