Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #17786 (again) -- Ensured destruction of test databases works u…

…nder Oracle, even with multiple databases, after r17411.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17601 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 97061bdf30216adfe50a1a367ddeefe06af5fefc 1 parent de9942a
Aymeric Augustin aaugustin authored
4 django/db/backends/creation.py
View
@@ -353,7 +353,7 @@ def _create_test_db(self, verbosity, autoclobber):
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 @@ def destroy_test_db(self, old_database_name, verbosity=1):
# 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'])
18 django/db/backends/oracle/creation.py
View
@@ -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 @@ def _create_test_db(self, verbosity=1, autoclobber=False):
'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 @@ def _create_test_db(self, verbosity=1, autoclobber=False):
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 @@ def _destroy_test_db(self, test_database_name, verbosity=1):
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,
Please sign in to comment.
Something went wrong with that request. Please try again.