diff --git a/django/db/backends/creation.py b/django/db/backends/creation.py index 2db0acca7cd..0cd055866a3 100644 --- a/django/db/backends/creation.py +++ b/django/db/backends/creation.py @@ -353,7 +353,7 @@ class BaseDatabaseCreation(object): def destroy_test_db(self, old_database_name, verbosity=1): """ Destroy a test database, prompting the user for confirmation if the - database already exists. Returns the name of the test database created. + database already exists. """ self.connection.close() test_database_name = self.connection.settings_dict['NAME'] @@ -367,7 +367,7 @@ class BaseDatabaseCreation(object): # Temporarily use a new connection and a copy of the settings dict. # This prevents the production database from being exposed to potential # child threads while (or after) the test database is destroyed. - # Refs #10868. + # Refs #10868 and #17786. settings_dict = self.connection.settings_dict.copy() settings_dict['NAME'] = old_database_name backend = load_backend(settings_dict['ENGINE']) diff --git a/django/db/backends/oracle/creation.py b/django/db/backends/oracle/creation.py index c6b04da57fe..9e6133fc642 100644 --- a/django/db/backends/oracle/creation.py +++ b/django/db/backends/oracle/creation.py @@ -40,11 +40,6 @@ class DatabaseCreation(BaseDatabaseCreation): 'URLField': 'VARCHAR2(%(max_length)s)', } - # This dictionary stores the original values of user and passwd, which are - # changed during the tests. It's stored at the class level because the - # test database is created and destroyed by different connections (#17786). - remember = {} - def __init__(self, connection): super(DatabaseCreation, self).__init__(connection) @@ -63,9 +58,6 @@ class DatabaseCreation(BaseDatabaseCreation): 'tblspace_temp': TEST_TBLSPACE_TMP, } - self.remember['user'] = self.connection.settings_dict['USER'] - self.remember['passwd'] = self.connection.settings_dict['PASSWORD'] - cursor = self.connection.cursor() if self._test_database_create(): try: @@ -111,8 +103,10 @@ class DatabaseCreation(BaseDatabaseCreation): print "Tests cancelled." sys.exit(1) - self.connection.settings_dict['TEST_USER'] = self.connection.settings_dict["USER"] = TEST_USER - self.connection.settings_dict["PASSWORD"] = TEST_PASSWD + self.connection.settings_dict['SAVED_USER'] = self.connection.settings_dict['USER'] + self.connection.settings_dict['SAVED_PASSWORD'] = self.connection.settings_dict['PASSWORD'] + self.connection.settings_dict['TEST_USER'] = self.connection.settings_dict['USER'] = TEST_USER + self.connection.settings_dict['PASSWORD'] = TEST_PASSWD return self.connection.settings_dict['NAME'] @@ -127,8 +121,8 @@ class DatabaseCreation(BaseDatabaseCreation): TEST_TBLSPACE = self._test_database_tblspace() TEST_TBLSPACE_TMP = self._test_database_tblspace_tmp() - self.connection.settings_dict["USER"] = self.remember['user'] - self.connection.settings_dict["PASSWORD"] = self.remember['passwd'] + self.connection.settings_dict['USER'] = self.connection.settings_dict['SAVED_USER'] + self.connection.settings_dict['PASSWORD'] = self.connection.settings_dict['SAVED_PASSWORD'] parameters = { 'dbname': TEST_NAME,