Tests that require a database (namely, model tests) will not use your production database; separate, blank databases are created for the tests. Regardless of whether the tests pass or fail, the test databases are destroyed when all the tests have been executed. You can prevent the test databases from being destroyed by adding the -keepdb
flag to the test command. This will preserve the test database between runs.
If the database does not exist, it will first be created. Any migrations will also be applied in order to keep it up to date. By default, the test databases get their names by prepending test_
to the value of the NAME
settings for the databases defined in DATABASES
. When using the SQLite database engine, the tests will by default use an in-memory database (that is, the database will be created in memory, bypassing the filesystem entirely!).
If you want to use a different database name, specify NAME
in the TEST
dictionary for any given database in DATABASES
. On PostgreSQL...