Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force delete of any previous test database (autoclobber) when running Django unit tests, eg, in PyCharm

I am running Django unit tests against a multithreaded app. Often a thread hasn't terminated by the time the unit test finishes, so the test database cannot be deleted. When I next run the tests, I get the message:

Type 'yes' if you would like to try deleting the test database 'test_appname', or 'no' to cancel`

The create_test_db autoclobber option is the functionality I want, but how can I use that? I can't find any examples or clues. I'm working in the PyCharm IDE, which is pretty configurable. I just want to delete the test database silently every time.

I'm putting tests in Transaction TestCase classes, running setup_test_environment() then Client().post(reverse(etc..))..

like image 730
Chris Avatar asked Dec 12 '15 19:12

Chris


1 Answers

In Pycharm django tests, you can enable the option input and enter --noinput

see screenshot below

enter image description here

like image 98
Dr Manhattan Avatar answered Sep 22 '22 15:09

Dr Manhattan