Tweaked order of create_test_db arguments for backwards compatibility.
Since `serialize` was backported to 1.7, it should appear before `keepdb`.
This commit is contained in:
parent
67ce2e74e1
commit
3a926c0778
|
@ -337,7 +337,7 @@ class BaseDatabaseCreation(object):
|
||||||
";",
|
";",
|
||||||
]
|
]
|
||||||
|
|
||||||
def create_test_db(self, verbosity=1, autoclobber=False, keepdb=False, serialize=True):
|
def create_test_db(self, verbosity=1, autoclobber=False, serialize=True, keepdb=False):
|
||||||
"""
|
"""
|
||||||
Creates a test database, prompting the user for confirmation if the
|
Creates a test database, prompting the user for confirmation if the
|
||||||
database already exists. Returns the name of the test database created.
|
database already exists. Returns the name of the test database created.
|
||||||
|
@ -419,6 +419,7 @@ class BaseDatabaseCreation(object):
|
||||||
app_config.name not in settings.TEST_NON_SERIALIZED_APPS
|
app_config.name not in settings.TEST_NON_SERIALIZED_APPS
|
||||||
):
|
):
|
||||||
app_list.append((app_config, None))
|
app_list.append((app_config, None))
|
||||||
|
|
||||||
# Make a function to iteratively return every object
|
# Make a function to iteratively return every object
|
||||||
def get_objects():
|
def get_objects():
|
||||||
for model in sort_dependencies(app_list):
|
for model in sort_dependencies(app_list):
|
||||||
|
|
|
@ -485,7 +485,7 @@ django.db.connection.creation
|
||||||
The creation module of the database backend also provides some utilities that
|
The creation module of the database backend also provides some utilities that
|
||||||
can be useful during testing.
|
can be useful during testing.
|
||||||
|
|
||||||
.. function:: create_test_db([verbosity=1, autoclobber=False, keepdb=False, serialize=True])
|
.. function:: create_test_db([verbosity=1, autoclobber=False, serialize=True, keepdb=False])
|
||||||
|
|
||||||
Creates a new test database and runs ``migrate`` against it.
|
Creates a new test database and runs ``migrate`` against it.
|
||||||
|
|
||||||
|
@ -501,24 +501,32 @@ can be useful during testing.
|
||||||
* If autoclobber is ``True``, the database will be destroyed
|
* If autoclobber is ``True``, the database will be destroyed
|
||||||
without consulting the user.
|
without consulting the user.
|
||||||
|
|
||||||
``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.
|
|
||||||
|
|
||||||
``serialize`` determines if Django serializes the database into an
|
``serialize`` determines if Django serializes the database into an
|
||||||
in-memory JSON string before running tests (used to restore the database
|
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
|
state between tests if you don't have transactions). You can set this to
|
||||||
False to significantly speed up creation time if you know you don't need
|
False to significantly speed up creation time if you know you don't need
|
||||||
data persistance outside of test fixtures.
|
data persistance outside of test fixtures.
|
||||||
|
|
||||||
|
``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.
|
Returns the name of the test database that it created.
|
||||||
|
|
||||||
``create_test_db()`` has the side effect of modifying the value of
|
``create_test_db()`` has the side effect of modifying the value of
|
||||||
:setting:`NAME` in :setting:`DATABASES` to match the name of the test
|
:setting:`NAME` in :setting:`DATABASES` to match the name of the test
|
||||||
database.
|
database.
|
||||||
|
|
||||||
|
.. versionchanged:: 1.7
|
||||||
|
|
||||||
|
The ``serialize`` argument was added.
|
||||||
|
|
||||||
|
.. versionchanged:: 1.8
|
||||||
|
|
||||||
|
The ``keepdb`` argument was added.
|
||||||
|
|
||||||
.. function:: destroy_test_db(old_database_name, [verbosity=1, keepdb=False])
|
.. function:: destroy_test_db(old_database_name, [verbosity=1, keepdb=False])
|
||||||
|
|
||||||
Destroys the database whose name is the value of :setting:`NAME` in
|
Destroys the database whose name is the value of :setting:`NAME` in
|
||||||
|
@ -531,6 +539,10 @@ can be useful during testing.
|
||||||
If the ``keepdb`` argument is ``True``, then the connection to the
|
If the ``keepdb`` argument is ``True``, then the connection to the
|
||||||
database will be closed, but the database will not be destroyed.
|
database will be closed, but the database will not be destroyed.
|
||||||
|
|
||||||
|
.. versionchanged:: 1.8
|
||||||
|
|
||||||
|
The ``keepdb`` argument was added.
|
||||||
|
|
||||||
.. _topics-testing-code-coverage:
|
.. _topics-testing-code-coverage:
|
||||||
|
|
||||||
Integration with coverage.py
|
Integration with coverage.py
|
||||||
|
|
Loading…
Reference in New Issue