How to automatically destroy django test database

Ric W picture Ric W · Aug 24, 2012 · Viewed 13.3k times · Source

I'm currently trying to automate django tests using hudson, and am struggling to find an option that will automatically destroy the test database if it already exists (typically it will ask for confirmation to destroy it, which the automatic testing obviously cannot provide for).

Any suggestions would be much appreciated!

Cheers, R

Answer

jpic picture jpic · Aug 24, 2012

Use --help to see the docs of the test command:

>>> ./manage.py test --help   
Usage: ./manage.py test [options] [appname ...]

Runs the test suite for the specified applications, or the entire site if no apps are specified.

[...]

--noinput             Tells Django to NOT prompt the user for input of any
                      kind.

And use --noinput which defaults to destroying the test db;)