diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2014-06-06 14:05:41 +0200 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2014-06-06 14:05:41 +0200 |
| commit | 1181b8a4a95551659be6737e41e9fc9d23eb8df4 (patch) | |
| tree | 48888c915997e1b71f57c2e6d1f75c748b795be0 /docs | |
| parent | daaeb8415823444a9020460cf825efc3fae866a2 (diff) | |
| parent | 72f055e535fb25f8b18be031f8fe18674c1d7f6a (diff) | |
Merge pull request #2764 from gchp/ticket-20550
Fixed #20550 -- Added keepdb argument to destroy_test_db
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/topics/testing/advanced.txt | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/docs/topics/testing/advanced.txt b/docs/topics/testing/advanced.txt index 046f663672..13041c1945 100644 --- a/docs/topics/testing/advanced.txt +++ b/docs/topics/testing/advanced.txt @@ -485,7 +485,7 @@ django.db.connection.creation The creation module of the database backend also provides some utilities that can be useful during testing. -.. function:: create_test_db([verbosity=1, autoclobber=False]) +.. function:: create_test_db([verbosity=1, autoclobber=False, keepdb=False]) Creates a new test database and runs ``migrate`` against it. @@ -501,13 +501,19 @@ can be useful during testing. * If autoclobber is ``True``, the database will be destroyed 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. + Returns the name of the test database that it created. ``create_test_db()`` has the side effect of modifying the value of :setting:`NAME` in :setting:`DATABASES` to match the name of the test database. -.. function:: destroy_test_db(old_database_name, [verbosity=1]) +.. function:: destroy_test_db(old_database_name, [verbosity=1, keepdb=False]) Destroys the database whose name is the value of :setting:`NAME` in :setting:`DATABASES`, and sets :setting:`NAME` to the value of @@ -516,6 +522,9 @@ can be useful during testing. The ``verbosity`` argument has the same behavior as for :class:`~django.test.runner.DiscoverRunner`. + If the ``keepdb`` argument is ``True``, then the connection to the + database will be closed, but the database will not be destroyed. + .. _topics-testing-code-coverage: Integration with coverage.py |
