Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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 authored February 28, 2012
4  django/db/backends/creation.py
@@ -353,7 +353,7 @@ def _create_test_db(self, verbosity, autoclobber):
353 353
     def destroy_test_db(self, old_database_name, verbosity=1):
354 354
         """
355 355
         Destroy a test database, prompting the user for confirmation if the
356  
-        database already exists. Returns the name of the test database created.
  356
+        database already exists.
357 357
         """
358 358
         self.connection.close()
359 359
         test_database_name = self.connection.settings_dict['NAME']
@@ -367,7 +367,7 @@ def destroy_test_db(self, old_database_name, verbosity=1):
367 367
         # Temporarily use a new connection and a copy of the settings dict.
368 368
         # This prevents the production database from being exposed to potential
369 369
         # child threads while (or after) the test database is destroyed.
370  
-        # Refs #10868.
  370
+        # Refs #10868 and #17786.
371 371
         settings_dict = self.connection.settings_dict.copy()
372 372
         settings_dict['NAME'] = old_database_name
373 373
         backend = load_backend(settings_dict['ENGINE'])
18  django/db/backends/oracle/creation.py
@@ -40,11 +40,6 @@ class DatabaseCreation(BaseDatabaseCreation):
40 40
         'URLField':                     'VARCHAR2(%(max_length)s)',
41 41
     }
42 42
 
43  
-    # This dictionary stores the original values of user and passwd, which are
44  
-    # changed during the tests. It's stored at the class level because the
45  
-    # test database is created and destroyed by different connections (#17786).
46  
-    remember = {}
47  
-
48 43
     def __init__(self, connection):
49 44
         super(DatabaseCreation, self).__init__(connection)
50 45
 
@@ -63,9 +58,6 @@ def _create_test_db(self, verbosity=1, autoclobber=False):
63 58
             'tblspace_temp': TEST_TBLSPACE_TMP,
64 59
         }
65 60
 
66  
-        self.remember['user'] = self.connection.settings_dict['USER']
67  
-        self.remember['passwd'] = self.connection.settings_dict['PASSWORD']
68  
-
69 61
         cursor = self.connection.cursor()
70 62
         if self._test_database_create():
71 63
             try:
@@ -111,8 +103,10 @@ def _create_test_db(self, verbosity=1, autoclobber=False):
111 103
                     print "Tests cancelled."
112 104
                     sys.exit(1)
113 105
 
114  
-        self.connection.settings_dict['TEST_USER'] = self.connection.settings_dict["USER"] = TEST_USER
115  
-        self.connection.settings_dict["PASSWORD"] = TEST_PASSWD
  106
+        self.connection.settings_dict['SAVED_USER'] = self.connection.settings_dict['USER']
  107
+        self.connection.settings_dict['SAVED_PASSWORD'] = self.connection.settings_dict['PASSWORD']
  108
+        self.connection.settings_dict['TEST_USER'] = self.connection.settings_dict['USER'] = TEST_USER
  109
+        self.connection.settings_dict['PASSWORD'] = TEST_PASSWD
116 110
 
117 111
         return self.connection.settings_dict['NAME']
118 112
 
@@ -127,8 +121,8 @@ def _destroy_test_db(self, test_database_name, verbosity=1):
127 121
         TEST_TBLSPACE = self._test_database_tblspace()
128 122
         TEST_TBLSPACE_TMP = self._test_database_tblspace_tmp()
129 123
 
130  
-        self.connection.settings_dict["USER"] = self.remember['user']
131  
-        self.connection.settings_dict["PASSWORD"] = self.remember['passwd']
  124
+        self.connection.settings_dict['USER'] = self.connection.settings_dict['SAVED_USER']
  125
+        self.connection.settings_dict['PASSWORD'] = self.connection.settings_dict['SAVED_PASSWORD']
132 126
 
133 127
         parameters = {
134 128
             'dbname': TEST_NAME,

0 notes on commit 97061bd

Please sign in to comment.
Something went wrong with that request. Please try again.