From 49c438fd219c8bc1ee1a32b98ef3777abeb289f6 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Thu, 16 Aug 2007 22:46:00 +0000 Subject: [PATCH] Changed django.test.utils.create_test_db to return the name of the test database that was created git-svn-id: http://code.djangoproject.com/svn/django/trunk@5910 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/test/utils.py | 6 ++++++ docs/testing.txt | 3 +++ 2 files changed, 9 insertions(+) diff --git a/django/test/utils.py b/django/test/utils.py index ae3798634e..bc53ef4bfb 100644 --- a/django/test/utils.py +++ b/django/test/utils.py @@ -90,6 +90,10 @@ def get_postgresql_create_suffix(): return '' def create_test_db(verbosity=1, autoclobber=False): + """ + Creates a test database, prompting the user for confirmation if the + database already exists. Returns the name of the test database created. + """ # If the database backend wants to create the test DB itself, let it creation_module = get_creation_module() if hasattr(creation_module, "create_test_db"): @@ -153,6 +157,8 @@ def create_test_db(verbosity=1, autoclobber=False): # the side effect of initializing the test database. cursor = connection.cursor() + return TEST_DATABASE_NAME + def destroy_test_db(old_database_name, verbosity=1): # If the database wants to drop the test DB itself, let it creation_module = get_creation_module() diff --git a/docs/testing.txt b/docs/testing.txt index c0d8ec8877..4e723a1020 100644 --- a/docs/testing.txt +++ b/docs/testing.txt @@ -988,6 +988,9 @@ a number of utility methods in the ``django.test.utils`` module. ``create_test_db()`` has the side effect of modifying ``settings.DATABASE_NAME`` to match the name of the test database. + New in the Django development version, this function returns the name of + the test database that it created. + ``destroy_test_db(old_database_name, verbosity=1)`` Destroys the database whose name is in the ``DATABASE_NAME`` setting and restores the value of ``DATABASE_NAME`` to the provided name.