create_test_db(verbosity=1, autoclobber=False, serialize=True, keepdb=False)
Creates a new test database and runs migrate
against it.
verbosity
has the same behavior as in run_tests()
.
autoclobber
describes the behavior that will occur if a database with the same name as the test database is discovered:
- If
autoclobber
isFalse
, the user will be asked to approve destroying the existing database.sys.exit
is called if the user does not approve. - If autoclobber is
True
, the database will be destroyed without consulting the user.
serialize
determines if Django serializes the database into an in-memory JSON string before running tests (used to restore the database state between tests if you don’t have transactions). You can set this to False
to speed up creation time if you don’t have any test classes with serialized_rollback=True.
If you are using the default test runner, you can control this with the the SERIALIZE
entry in the TEST
dictionary.
keepdb
determines if the test run should use an existing database, or create a new one. If True
, the existing database will be used, or created if not present. If False
, a new database will be created, prompting the user to remove the existing one, if present.
Returns the name of the test database that it created.
create_test_db()
has the side effect of modifying the value of NAME
in DATABASES
to match the name of the test database.
Please login to continue.