diff --git a/django/db/backends/creation.py b/django/db/backends/creation.py
a
|
b
|
|
462 | 462 | def sql_table_creation_suffix(self): |
463 | 463 | "SQL to append to the end of the test table creation statements" |
464 | 464 | return '' |
| 465 | |
| 466 | def test_db_signature(self): |
| 467 | """ |
| 468 | Returns a tuple with elements of self.connection.settings_dict (a |
| 469 | DATABASES setting value) that uniquely identify a database |
| 470 | accordingly to the RDBMS particularities. |
| 471 | """ |
| 472 | settings_dict = self.connection.settings_dict |
| 473 | return ( |
| 474 | settings_dict['HOST'], |
| 475 | settings_dict['PORT'], |
| 476 | settings_dict['ENGINE'], |
| 477 | settings_dict['NAME'] |
| 478 | ) |
diff --git a/django/db/backends/oracle/creation.py b/django/db/backends/oracle/creation.py
a
|
b
|
|
259 | 259 | names as handled by Django haven't real counterparts in Oracle. |
260 | 260 | """ |
261 | 261 | return self.connection.settings_dict['NAME'] |
| 262 | |
| 263 | def test_db_signature(self): |
| 264 | settings_dict = self.connection.settings_dict |
| 265 | return ( |
| 266 | settings_dict['HOST'], |
| 267 | settings_dict['PORT'], |
| 268 | settings_dict['ENGINE'], |
| 269 | settings_dict['NAME'], |
| 270 | settings_dict['TEST_TBLSPACE'], |
| 271 | ) |
diff --git a/django/test/simple.py b/django/test/simple.py
a
|
b
|
|
1 | | import sys |
2 | | import signal |
3 | | |
4 | 1 | from django.conf import settings |
5 | 2 | from django.core.exceptions import ImproperlyConfigured |
6 | 3 | from django.db.models import get_app, get_apps |
… |
… |
|
203 | 200 | deferred = [] |
204 | 201 | |
205 | 202 | while test_databases: |
206 | | signature, aliases = test_databases.pop() |
| 203 | signature, (db_name, aliases) = test_databases.pop() |
207 | 204 | dependencies_satisfied = True |
208 | 205 | for alias in aliases: |
209 | 206 | if alias in dependencies: |
… |
… |
|
217 | 214 | resolved_databases.add(alias) |
218 | 215 | |
219 | 216 | if dependencies_satisfied: |
220 | | ordered_test_databases.append((signature, aliases)) |
| 217 | ordered_test_databases.append((signature, (db_name, aliases))) |
221 | 218 | changed = True |
222 | 219 | else: |
223 | | deferred.append((signature, aliases)) |
| 220 | deferred.append((signature, (db_name, aliases))) |
224 | 221 | |
225 | 222 | if not changed: |
226 | 223 | raise ImproperlyConfigured("Circular dependency in TEST_DEPENDENCIES") |
… |
… |
|
276 | 273 | # Store a tuple with DB parameters that uniquely identify it. |
277 | 274 | # If we have two aliases with the same values for that tuple, |
278 | 275 | # we only need to create the test database once. |
279 | | test_databases.setdefault(( |
280 | | connection.settings_dict['HOST'], |
281 | | connection.settings_dict['PORT'], |
282 | | connection.settings_dict['ENGINE'], |
283 | | connection.settings_dict['NAME'], |
284 | | ), []).append(alias) |
| 276 | item = test_databases.setdefault( |
| 277 | connection.creation.test_db_signature(), |
| 278 | (connection.settings_dict['NAME'], []) |
| 279 | ) |
| 280 | item[1].append(alias) |
285 | 281 | |
286 | 282 | if 'TEST_DEPENDENCIES' in connection.settings_dict: |
287 | 283 | dependencies[alias] = connection.settings_dict['TEST_DEPENDENCIES'] |
… |
… |
|
292 | 288 | # Second pass -- actually create the databases. |
293 | 289 | old_names = [] |
294 | 290 | mirrors = [] |
295 | | for (host, port, engine, db_name), aliases in dependency_ordered(test_databases.items(), dependencies): |
| 291 | for signature, (db_name, aliases) in dependency_ordered(test_databases.items(), dependencies): |
296 | 292 | # Actually create the database for the first connection |
297 | 293 | connection = connections[aliases[0]] |
298 | 294 | old_names.append((connection, db_name, True)) |
diff --git a/tests/regressiontests/test_runner/tests.py b/tests/regressiontests/test_runner/tests.py
a
|
b
|
|
33 | 33 | |
34 | 34 | def test_simple_dependencies(self): |
35 | 35 | raw = [ |
36 | | ('s1', ['alpha']), |
37 | | ('s2', ['bravo']), |
38 | | ('s3', ['charlie']), |
| 36 | ('s1', ('s1_db', ['alpha'])), |
| 37 | ('s2', ('s2_db', ['bravo'])), |
| 38 | ('s3', ('s3_db', ['charlie'])), |
39 | 39 | ] |
40 | 40 | dependencies = { |
41 | 41 | 'alpha': ['charlie'], |
… |
… |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | ordered = simple.dependency_ordered(raw, dependencies=dependencies) |
46 | | ordered_sigs = [sig for sig,aliases in ordered] |
| 46 | ordered_sigs = [sig for sig,value in ordered] |
47 | 47 | |
48 | 48 | self.assertIn('s1', ordered_sigs) |
49 | 49 | self.assertIn('s2', ordered_sigs) |
… |
… |
|
53 | 53 | |
54 | 54 | def test_chained_dependencies(self): |
55 | 55 | raw = [ |
56 | | ('s1', ['alpha']), |
57 | | ('s2', ['bravo']), |
58 | | ('s3', ['charlie']), |
| 56 | ('s1', ('s1_db', ['alpha'])), |
| 57 | ('s2', ('s2_db', ['bravo'])), |
| 58 | ('s3', ('s3_db', ['charlie'])), |
59 | 59 | ] |
60 | 60 | dependencies = { |
61 | 61 | 'alpha': ['bravo'], |
… |
… |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | ordered = simple.dependency_ordered(raw, dependencies=dependencies) |
66 | | ordered_sigs = [sig for sig,aliases in ordered] |
| 66 | ordered_sigs = [sig for sig,value in ordered] |
67 | 67 | |
68 | 68 | self.assertIn('s1', ordered_sigs) |
69 | 69 | self.assertIn('s2', ordered_sigs) |
… |
… |
|
78 | 78 | |
79 | 79 | def test_multiple_dependencies(self): |
80 | 80 | raw = [ |
81 | | ('s1', ['alpha']), |
82 | | ('s2', ['bravo']), |
83 | | ('s3', ['charlie']), |
84 | | ('s4', ['delta']), |
| 81 | ('s1', ('s1_db', ['alpha'])), |
| 82 | ('s2', ('s2_db', ['bravo'])), |
| 83 | ('s3', ('s3_db', ['charlie'])), |
| 84 | ('s4', ('s4_db', ['delta'])), |
85 | 85 | ] |
86 | 86 | dependencies = { |
87 | 87 | 'alpha': ['bravo','delta'], |
… |
… |
|
108 | 108 | |
109 | 109 | def test_circular_dependencies(self): |
110 | 110 | raw = [ |
111 | | ('s1', ['alpha']), |
112 | | ('s2', ['bravo']), |
| 111 | ('s1', ('s1_db', ['alpha'])), |
| 112 | ('s2', ('s2_db', ['bravo'])), |
113 | 113 | ] |
114 | 114 | dependencies = { |
115 | 115 | 'bravo': ['alpha'], |