Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[soc2009/multidb] Purged all remaining references to DATABASE_* setti…

…ngs and TEST_DATABASE_* settings from the database backends, all of these settings have been moved into dictionaries in the DATABASES setting

git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/multidb@10894 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit f280c325cda1364689fefdda853173e1e05591bf 1 parent 1dc3305
Alex Gaynor authored June 03, 2009
1  TODO.TXT
@@ -28,7 +28,6 @@ that need to be done.  I'm trying to be as granular as possible.
28 28
 
29 29
 4)  Rig up the test harness to work with multiple databases.  This includes:
30 30
 
31  
-    * Move all ``TEST_*`` settings to go in ``DATABASE_OPTIONS``.
32 31
     * Figure out how we can actually test multiple databases.  If the user has
33 32
       more than one database in ``settings.DATABASES`` we can just use the test
34 33
       database for each of them.  Otherwise we are going to have to make some
13  django/db/__init__.py
@@ -4,10 +4,13 @@
4 4
 from django.db.utils import ConnectionHandler, load_backend
5 5
 from django.utils.functional import curry
6 6
 
7  
-__all__ = ('backend', 'connection', 'DatabaseError', 'IntegrityError')
  7
+__all__ = ('backend', 'connection', 'connections', 'DatabaseError',
  8
+    'IntegrityError', 'DEFAULT_DB_ALIAS')
8 9
 
9  
-if not settings.DATABASES or 'default' not in settings.DATABASES:
10  
-    settings.DATABASES['default'] = {
  10
+DEFAULT_DB_ALIAS = 'default'
  11
+
  12
+if not settings.DATABASES or DEFAULT_DB_ALIAS not in settings.DATABASES:
  13
+    settings.DATABASES[DEFAULT_DB_ALIAS] = {
11 14
         'DATABASE_ENGINE': settings.DATABASE_ENGINE,
12 15
         'DATABASE_HOST': settings.DATABASE_HOST,
13 16
         'DATABASE_NAME': settings.DATABASE_NAME,
@@ -16,6 +19,10 @@
16 19
         'DATABASE_PORT': settings.DATABASE_PORT,
17 20
         'DATABASE_USER': settings.DATABASE_USER,
18 21
         'TIME_ZONE': settings.TIME_ZONE,
  22
+
  23
+        'TEST_DATABASE_CHARSET': settings.TEST_DATABASE_CHARSET,
  24
+        'TEST_DATABASE_COLLATION': settings.TEST_DATABASE_COLLATION,
  25
+        'TEST_DATABASE_NAME': settings.TEST_DATABASE_NAME,
19 26
     }
20 27
 
21 28
 connections = ConnectionHandler(settings.DATABASES)
4  django/db/backends/__init__.py
@@ -557,7 +557,9 @@ class BaseDatabaseValidation(object):
557 557
     """
558 558
     This class encapsualtes all backend-specific model validation.
559 559
     """
  560
+    def __init__(self, connection):
  561
+        self.connection = connection
  562
+
560 563
     def validate_field(self, errors, opts, f):
561 564
         "By default, there is no backend-specific validation"
562 565
         pass
563  
-
14  django/db/backends/creation.py
@@ -321,10 +321,8 @@ def create_test_db(self, verbosity=1, autoclobber=False):
321 321
         test_database_name = self._create_test_db(verbosity, autoclobber)
322 322
 
323 323
         self.connection.close()
324  
-        settings.DATABASE_NAME = test_database_name
325 324
         self.connection.settings_dict["DATABASE_NAME"] = test_database_name
326 325
         can_rollback = self._rollback_works()
327  
-        settings.DATABASE_SUPPORTS_TRANSACTIONS = can_rollback
328 326
         self.connection.settings_dict["DATABASE_SUPPORTS_TRANSACTIONS"] = can_rollback
329 327
 
330 328
         call_command('syncdb', verbosity=verbosity, interactive=False)
@@ -344,10 +342,10 @@ def _create_test_db(self, verbosity, autoclobber):
344 342
         "Internal implementation - creates the test db tables."
345 343
         suffix = self.sql_table_creation_suffix()
346 344
 
347  
-        if settings.TEST_DATABASE_NAME:
348  
-            test_database_name = settings.TEST_DATABASE_NAME
  345
+        if self.connection.settings_dict['TEST_DATABASE_NAME']:
  346
+            test_database_name = self.connection.settings_dict['TEST_DATABASE_NAME']
349 347
         else:
350  
-            test_database_name = TEST_DATABASE_PREFIX + settings.DATABASE_NAME
  348
+            test_database_name = TEST_DATABASE_PREFIX + self.connection.settings_dict['DATABASE_NAME']
351 349
 
352 350
         qn = self.connection.ops.quote_name
353 351
 
@@ -399,9 +397,8 @@ def destroy_test_db(self, old_database_name, verbosity=1):
399 397
         if verbosity >= 1:
400 398
             print "Destroying test database..."
401 399
         self.connection.close()
402  
-        test_database_name = settings.DATABASE_NAME
403  
-        settings.DATABASE_NAME = old_database_name
404  
-        self.connection.settings_dict["DATABASE_NAME"] = old_database_name
  400
+        test_database_name = self.connection.settings_dict['DATABASE_NAME']
  401
+        self.connection.settings_dict['DATABASE_NAME'] = old_database_name
405 402
 
406 403
         self._destroy_test_db(test_database_name, verbosity)
407 404
 
@@ -430,4 +427,3 @@ def set_autocommit(self):
430 427
     def sql_table_creation_suffix(self):
431 428
         "SQL to append to the end of the test table creation statements"
432 429
         return ''
433  
-
2  django/db/backends/mysql/base.py
@@ -242,7 +242,7 @@ def __init__(self, *args, **kwargs):
242 242
         self.client = DatabaseClient(self)
243 243
         self.creation = DatabaseCreation(self)
244 244
         self.introspection = DatabaseIntrospection(self)
245  
-        self.validation = DatabaseValidation()
  245
+        self.validation = DatabaseValidation(self)
246 246
 
247 247
     def _valid_connection(self):
248 248
         if self.connection is not None:
14  django/db/backends/mysql/creation.py
... ...
@@ -1,4 +1,3 @@
1  
-from django.conf import settings
2 1
 from django.db.backends.creation import BaseDatabaseCreation
3 2
 
4 3
 class DatabaseCreation(BaseDatabaseCreation):
@@ -31,21 +30,21 @@ class DatabaseCreation(BaseDatabaseCreation):
31 30
 
32 31
     def sql_table_creation_suffix(self):
33 32
         suffix = []
34  
-        if settings.TEST_DATABASE_CHARSET:
35  
-            suffix.append('CHARACTER SET %s' % settings.TEST_DATABASE_CHARSET)
36  
-        if settings.TEST_DATABASE_COLLATION:
37  
-            suffix.append('COLLATE %s' % settings.TEST_DATABASE_COLLATION)
  33
+        if self.connection.settings_dict['TEST_DATABASE_CHARSET']:
  34
+            suffix.append('CHARACTER SET %s' % self.connection.settings_dict['TEST_DATABASE_CHARSET'])
  35
+        if self.connection.settings_dict['TEST_DATABASE_COLLATION']:
  36
+            suffix.append('COLLATE %s' % self.connection.settings_dict['TEST_DATABASE_COLLATION'])
38 37
         return ' '.join(suffix)
39 38
 
40 39
     def sql_for_inline_foreign_key_references(self, field, known_models, style):
41 40
         "All inline references are pending under MySQL"
42 41
         return [], True
43  
-        
  42
+
44 43
     def sql_for_inline_many_to_many_references(self, model, field, style):
45 44
         from django.db import models
46 45
         opts = model._meta
47 46
         qn = self.connection.ops.quote_name
48  
-        
  47
+
49 48
         table_output = [
50 49
             '    %s %s %s,' %
51 50
                 (style.SQL_FIELD(qn(field.m2m_column_name())),
@@ -63,4 +62,3 @@ def sql_for_inline_many_to_many_references(self, model, field, style):
63 62
                 field.rel.to._meta.db_table, field.rel.to._meta.pk.column)
64 63
             ]
65 64
         return table_output, deferred
66  
-        
4  django/db/backends/mysql/validation.py
@@ -11,8 +11,7 @@ def validate_field(self, errors, opts, f):
11 11
           characters if they have a unique index on them.
12 12
         """
13 13
         from django.db import models
14  
-        from django.db import connection
15  
-        db_version = connection.get_server_version()
  14
+        db_version = self.connection.get_server_version()
16 15
         varchar_fields = (models.CharField, models.CommaSeparatedIntegerField,
17 16
                 models.SlugField)
18 17
         if isinstance(f, varchar_fields) and f.max_length > 255:
@@ -25,4 +24,3 @@ def validate_field(self, errors, opts, f):
25 24
 
26 25
             if msg:
27 26
                 errors.add(opts, msg % {'name': f.name, 'cls': f.__class__.__name__, 'version': '.'.join([str(n) for n in db_version[:3]])})
28  
-
2  django/db/backends/oracle/base.py
@@ -282,7 +282,7 @@ def __init__(self, *args, **kwargs):
282 282
         self.client = DatabaseClient(self)
283 283
         self.creation = DatabaseCreation(self)
284 284
         self.introspection = DatabaseIntrospection(self)
285  
-        self.validation = BaseDatabaseValidation()
  285
+        self.validation = BaseDatabaseValidation(self)
286 286
 
287 287
     def _valid_connection(self):
288 288
         return self.connection is not None
87  django/db/backends/oracle/creation.py
... ...
@@ -1,5 +1,4 @@
1 1
 import sys, time
2  
-from django.conf import settings
3 2
 from django.core import management
4 3
 from django.db.backends.creation import BaseDatabaseCreation
5 4
 
@@ -42,11 +41,11 @@ class DatabaseCreation(BaseDatabaseCreation):
42 41
     remember = {}
43 42
 
44 43
     def _create_test_db(self, verbosity=1, autoclobber=False):
45  
-        TEST_DATABASE_NAME = self._test_database_name(settings)
46  
-        TEST_DATABASE_USER = self._test_database_user(settings)
47  
-        TEST_DATABASE_PASSWD = self._test_database_passwd(settings)
48  
-        TEST_DATABASE_TBLSPACE = self._test_database_tblspace(settings)
49  
-        TEST_DATABASE_TBLSPACE_TMP = self._test_database_tblspace_tmp(settings)
  44
+        TEST_DATABASE_NAME = self._test_database_name()
  45
+        TEST_DATABASE_USER = self._test_database_user()
  46
+        TEST_DATABASE_PASSWD = self._test_database_passwd()
  47
+        TEST_DATABASE_TBLSPACE = self._test_database_tblspace()
  48
+        TEST_DATABASE_TBLSPACE_TMP = self._test_database_tblspace_tmp()
50 49
 
51 50
         parameters = {
52 51
             'dbname': TEST_DATABASE_NAME,
@@ -56,11 +55,11 @@ def _create_test_db(self, verbosity=1, autoclobber=False):
56 55
             'tblspace_temp': TEST_DATABASE_TBLSPACE_TMP,
57 56
         }
58 57
 
59  
-        self.remember['user'] = settings.DATABASE_USER
60  
-        self.remember['passwd'] = settings.DATABASE_PASSWORD
  58
+        self.remember['user'] = self.connection.settings_dict['DATABASE_USER']
  59
+        self.remember['passwd'] = self.connection.settings_dict['DATABASE_PASSWORD']
61 60
 
62 61
         cursor = self.connection.cursor()
63  
-        if self._test_database_create(settings):
  62
+        if self._test_database_create():
64 63
             if verbosity >= 1:
65 64
                 print 'Creating test database...'
66 65
             try:
@@ -84,7 +83,7 @@ def _create_test_db(self, verbosity=1, autoclobber=False):
84 83
                     print "Tests cancelled."
85 84
                     sys.exit(1)
86 85
 
87  
-        if self._test_user_create(settings):
  86
+        if self._test_user_create():
88 87
             if verbosity >= 1:
89 88
                 print "Creating test user..."
90 89
             try:
@@ -108,24 +107,24 @@ def _create_test_db(self, verbosity=1, autoclobber=False):
108 107
                     print "Tests cancelled."
109 108
                     sys.exit(1)
110 109
 
111  
-        settings.TEST_DATABASE_USER = settings.DATABASE_USER = self.connection.settings_dict["DATABASE_USER"] = TEST_DATABASE_USER
112  
-        settings.DATABASE_PASSWORD = self.connection.settings_dict["DATABASE_PASSWORD"] = TEST_DATABASE_PASSWD
  110
+        self.connection.settings_dict['TEST_DATABASE_USER'] = self.connection.settings_dict["DATABASE_USER"] = TEST_DATABASE_USER
  111
+        self.connection.settings_dict["DATABASE_PASSWORD"] = TEST_DATABASE_PASSWD
113 112
 
114  
-        return settings.DATABASE_NAME
  113
+        return self.connection.settings_dict['DATABASE_NAME']
115 114
 
116 115
     def _destroy_test_db(self, test_database_name, verbosity=1):
117 116
         """
118 117
         Destroy a test database, prompting the user for confirmation if the
119 118
         database already exists. Returns the name of the test database created.
120 119
         """
121  
-        TEST_DATABASE_NAME = self._test_database_name(settings)
122  
-        TEST_DATABASE_USER = self._test_database_user(settings)
123  
-        TEST_DATABASE_PASSWD = self._test_database_passwd(settings)
124  
-        TEST_DATABASE_TBLSPACE = self._test_database_tblspace(settings)
125  
-        TEST_DATABASE_TBLSPACE_TMP = self._test_database_tblspace_tmp(settings)
  120
+        TEST_DATABASE_NAME = self._test_database_name()
  121
+        TEST_DATABASE_USER = self._test_database_user()
  122
+        TEST_DATABASE_PASSWD = self._test_database_passwd()
  123
+        TEST_DATABASE_TBLSPACE = self._test_database_tblspace()
  124
+        TEST_DATABASE_TBLSPACE_TMP = self._test_database_tblspace_tmp()
126 125
 
127  
-        settings.DATABASE_USER = self.connection.settings_dict["DATABASE_USER"] = self.remember['user']
128  
-        settings.DATABASE_PASSWORD = self.connection.settings_dict["DATABASE_PASSWORD"] = self.remember['passwd']
  126
+        self.connection.settings_dict["DATABASE_USER"] = self.remember['user']
  127
+        self.connection.settings_dict["DATABASE_PASSWORD"] = self.remember['passwd']
129 128
 
130 129
         parameters = {
131 130
             'dbname': TEST_DATABASE_NAME,
@@ -135,16 +134,16 @@ def _destroy_test_db(self, test_database_name, verbosity=1):
135 134
             'tblspace_temp': TEST_DATABASE_TBLSPACE_TMP,
136 135
         }
137 136
 
138  
-        self.remember['user'] = settings.DATABASE_USER
139  
-        self.remember['passwd'] = settings.DATABASE_PASSWORD
  137
+        self.remember['user'] = self.connection.settings_dict['DATABASE_USER']
  138
+        self.remember['passwd'] = self.connection.settings_dict['DATABASE_PASSWORD']
140 139
 
141 140
         cursor = self.connection.cursor()
142 141
         time.sleep(1) # To avoid "database is being accessed by other users" errors.
143  
-        if self._test_user_create(settings):
  142
+        if self._test_user_create():
144 143
             if verbosity >= 1:
145 144
                 print 'Destroying test user...'
146 145
             self._destroy_test_user(cursor, parameters, verbosity)
147  
-        if self._test_database_create(settings):
  146
+        if self._test_database_create():
148 147
             if verbosity >= 1:
149 148
                 print 'Destroying test database tables...'
150 149
             self._execute_test_db_destruction(cursor, parameters, verbosity)
@@ -208,10 +207,10 @@ def _execute_statements(self, cursor, statements, parameters, verbosity):
208 207
                 raise
209 208
 
210 209
     def _test_database_name(self, settings):
211  
-        name = TEST_DATABASE_PREFIX + settings.DATABASE_NAME
  210
+        name = TEST_DATABASE_PREFIX + self.connection.settings_dict['DATABASE_NAME']
212 211
         try:
213  
-            if settings.TEST_DATABASE_NAME:
214  
-                name = settings.TEST_DATABASE_NAME
  212
+            if self.connection.settings_dict['TEST_DATABASE_NAME']:
  213
+                name = self.connection.settings_dict['TEST_DATABASE_NAME']
215 214
         except AttributeError:
216 215
             pass
217 216
         except:
@@ -221,11 +220,11 @@ def _test_database_name(self, settings):
221 220
     def _test_database_create(self, settings):
222 221
         name = True
223 222
         try:
224  
-            if settings.TEST_DATABASE_CREATE:
  223
+            if self.connection.setting_dict['TEST_DATABASE_CREATE']:
225 224
                 name = True
226 225
             else:
227 226
                 name = False
228  
-        except AttributeError:
  227
+        except KeyError:
229 228
             pass
230 229
         except:
231 230
             raise
@@ -234,32 +233,32 @@ def _test_database_create(self, settings):
234 233
     def _test_user_create(self, settings):
235 234
         name = True
236 235
         try:
237  
-            if settings.TEST_USER_CREATE:
  236
+            if self.connection.settings_dict['TEST_USER_CREATE']:
238 237
                 name = True
239 238
             else:
240 239
                 name = False
241  
-        except AttributeError:
  240
+        except KeyError:
242 241
             pass
243 242
         except:
244 243
             raise
245 244
         return name
246 245
 
247  
-    def _test_database_user(self, settings):
248  
-        name = TEST_DATABASE_PREFIX + settings.DATABASE_USER
  246
+    def _test_database_user(self):
  247
+        name = TEST_DATABASE_PREFIX + self.settings_dict['DATABASE_USER']
249 248
         try:
250  
-            if settings.TEST_DATABASE_USER:
251  
-                name = settings.TEST_DATABASE_USER
  249
+            if self.connection.settings_dict['TEST_DATABASE_USER']:
  250
+                name = self.connection.settings_dict['TEST_DATABASE_USER']
252 251
         except AttributeError:
253 252
             pass
254 253
         except:
255 254
             raise
256 255
         return name
257 256
 
258  
-    def _test_database_passwd(self, settings):
  257
+    def _test_database_passwd(self):
259 258
         name = PASSWORD
260 259
         try:
261  
-            if settings.TEST_DATABASE_PASSWD:
262  
-                name = settings.TEST_DATABASE_PASSWD
  260
+            if self.connection.settings_dict['TEST_DATABASE_PASSWD']:
  261
+                name = self.connection.settings_dict['TEST_DATABASE_PASSWD']
263 262
         except AttributeError:
264 263
             pass
265 264
         except:
@@ -267,10 +266,10 @@ def _test_database_passwd(self, settings):
267 266
         return name
268 267
 
269 268
     def _test_database_tblspace(self, settings):
270  
-        name = TEST_DATABASE_PREFIX + settings.DATABASE_NAME
  269
+        name = TEST_DATABASE_PREFIX + self.connection.settings_dict['DATABASE_NAME']
271 270
         try:
272  
-            if settings.TEST_DATABASE_TBLSPACE:
273  
-                name = settings.TEST_DATABASE_TBLSPACE
  271
+            if self.connection.settings_dict['TEST_DATABASE_TBLSPACE']:
  272
+                name = self.connection.settings_dict['TEST_DATABASE_TBLSPACE']
274 273
         except AttributeError:
275 274
             pass
276 275
         except:
@@ -278,10 +277,10 @@ def _test_database_tblspace(self, settings):
278 277
         return name
279 278
 
280 279
     def _test_database_tblspace_tmp(self, settings):
281  
-        name = TEST_DATABASE_PREFIX + settings.DATABASE_NAME + '_temp'
  280
+        name = TEST_DATABASE_PREFIX + self.connection.settings_dict['DATABASE_NAME'] + '_temp'
282 281
         try:
283  
-            if settings.TEST_DATABASE_TBLSPACE_TMP:
284  
-                name = settings.TEST_DATABASE_TBLSPACE_TMP
  282
+            if self.connection.settings_dict['TEST_DATABASE_TBLSPACE_TMP']:
  283
+                name = self.connection.settings_dict['TEST_DATABASE_TBLSPACE_TMP']
285 284
         except AttributeError:
286 285
             pass
287 286
         except:
2  django/db/backends/postgresql/base.py
@@ -94,7 +94,7 @@ def __init__(self, *args, **kwargs):
94 94
         self.client = DatabaseClient(self)
95 95
         self.creation = DatabaseCreation(self)
96 96
         self.introspection = DatabaseIntrospection(self)
97  
-        self.validation = BaseDatabaseValidation()
  97
+        self.validation = BaseDatabaseValidation(self)
98 98
 
99 99
     def _cursor(self):
100 100
         set_tz = False
7  django/db/backends/postgresql/creation.py
... ...
@@ -1,4 +1,3 @@
1  
-from django.conf import settings
2 1
 from django.db.backends.creation import BaseDatabaseCreation
3 2
 
4 3
 class DatabaseCreation(BaseDatabaseCreation):
@@ -30,7 +29,7 @@ class DatabaseCreation(BaseDatabaseCreation):
30 29
     }
31 30
 
32 31
     def sql_table_creation_suffix(self):
33  
-        assert settings.TEST_DATABASE_COLLATION is None, "PostgreSQL does not support collation setting at database creation time."
34  
-        if settings.TEST_DATABASE_CHARSET:
35  
-            return "WITH ENCODING '%s'" % settings.TEST_DATABASE_CHARSET
  32
+        assert self.connection.settings_dict['TEST_DATABASE_COLLATION'] is None, "PostgreSQL does not support collation setting at database creation time."
  33
+        if self.connection.settings_dict['TEST_DATABASE_CHARSET']:
  34
+            return "WITH ENCODING '%s'" % self.connection.settings_dict['TEST_DATABASE_CHARSET']
36 35
         return ''
4  django/db/backends/postgresql_psycopg2/base.py
@@ -4,7 +4,6 @@
4 4
 Requires psycopg 2: http://initd.org/projects/psycopg2
5 5
 """
6 6
 
7  
-from django.conf import settings
8 7
 from django.db.backends import *
9 8
 from django.db.backends.signals import connection_created
10 9
 from django.db.backends.postgresql.operations import DatabaseOperations as PostgresqlDatabaseOperations
@@ -71,7 +70,7 @@ def __init__(self, *args, **kwargs):
71 70
         self.client = DatabaseClient(self)
72 71
         self.creation = DatabaseCreation(self)
73 72
         self.introspection = DatabaseIntrospection(self)
74  
-        self.validation = BaseDatabaseValidation()
  73
+        self.validation = BaseDatabaseValidation(self)
75 74
 
76 75
     def _cursor(self):
77 76
         set_tz = False
@@ -150,4 +149,3 @@ def _set_isolation_level(self, level):
150 149
         finally:
151 150
             self.isolation_level = level
152 151
             self.features.uses_savepoints = bool(level)
153  
-
2  django/db/backends/sqlite3/base.py
@@ -154,7 +154,7 @@ def __init__(self, *args, **kwargs):
154 154
         self.client = DatabaseClient(self)
155 155
         self.creation = DatabaseCreation(self)
156 156
         self.introspection = DatabaseIntrospection(self)
157  
-        self.validation = BaseDatabaseValidation()
  157
+        self.validation = BaseDatabaseValidation(self)
158 158
 
159 159
     def _cursor(self):
160 160
         if self.connection is None:
11  django/db/backends/sqlite3/creation.py
... ...
@@ -1,6 +1,5 @@
1 1
 import os
2 2
 import sys
3  
-from django.conf import settings
4 3
 from django.db.backends.creation import BaseDatabaseCreation
5 4
 
6 5
 class DatabaseCreation(BaseDatabaseCreation):
@@ -29,7 +28,7 @@ class DatabaseCreation(BaseDatabaseCreation):
29 28
         'TextField':                    'text',
30 29
         'TimeField':                    'time',
31 30
     }
32  
-    
  31
+
33 32
     def sql_for_pending_references(self, model, style, pending_references):
34 33
         "SQLite3 doesn't support constraints"
35 34
         return []
@@ -37,10 +36,10 @@ def sql_for_pending_references(self, model, style, pending_references):
37 36
     def sql_remove_table_constraints(self, model, references_to_delete, style):
38 37
         "SQLite3 doesn't support constraints"
39 38
         return []
40  
-        
  39
+
41 40
     def _create_test_db(self, verbosity, autoclobber):
42  
-        if settings.TEST_DATABASE_NAME and settings.TEST_DATABASE_NAME != ":memory:":
43  
-            test_database_name = settings.TEST_DATABASE_NAME
  41
+        test_database_name = self.connection.settings_dict['TEST_DATABASE_NAME']
  42
+        if test_database_name and test_database_name != ":memory:":
44 43
             # Erase the old test database
45 44
             if verbosity >= 1:
46 45
                 print "Destroying old test database..."
@@ -63,7 +62,7 @@ def _create_test_db(self, verbosity, autoclobber):
63 62
         else:
64 63
             test_database_name = ":memory:"
65 64
         return test_database_name
66  
-        
  65
+
67 66
     def _destroy_test_db(self, test_database_name, verbosity):
68 67
         if test_database_name and test_database_name != ":memory:":
69 68
             # Remove the SQLite database file
4  django/test/testcases.py
@@ -436,7 +436,7 @@ class TestCase(TransactionTestCase):
436 436
     """
437 437
 
438 438
     def _fixture_setup(self):
439  
-        if not settings.DATABASE_SUPPORTS_TRANSACTIONS:
  439
+        if not connection.settings_dict['DATABASE_SUPPORTS_TRANSACTIONS']:
440 440
             return super(TestCase, self)._fixture_setup()
441 441
 
442 442
         transaction.enter_transaction_management()
@@ -453,7 +453,7 @@ def _fixture_setup(self):
453 453
                                                         })
454 454
 
455 455
     def _fixture_teardown(self):
456  
-        if not settings.DATABASE_SUPPORTS_TRANSACTIONS:
  456
+        if not connection.settings_dict['DATABASE_SUPPORTS_TRANSACTIONS']:
457 457
             return super(TestCase, self)._fixture_teardown()
458 458
 
459 459
         restore_transaction_methods()

0 notes on commit f280c32

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