diff options
| author | Ramiro Morales <cramm0@gmail.com> | 2011-02-02 14:02:14 +0000 |
|---|---|---|
| committer | Ramiro Morales <cramm0@gmail.com> | 2011-02-02 14:02:14 +0000 |
| commit | dc5f2607deb35022523fef17dcd8479ca812e887 (patch) | |
| tree | 88c1a08c9b1c0a8d5763f4a8412f3d15d7f47c7c /django/test | |
| parent | 77030ccc1ea4e1df04540e4d4594cb0d741fa2b4 (diff) | |
Fixed #15029 -- Moved to database backends the ability to decide if two DATABASES items are different when creating temporary databases for tests.
hG: Enter commit message. Lines beginning with 'HG:' are removed.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15392 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/test')
| -rw-r--r-- | django/test/simple.py | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/django/test/simple.py b/django/test/simple.py index 1b26ebbe74..c1230678a7 100644 --- a/django/test/simple.py +++ b/django/test/simple.py @@ -1,6 +1,3 @@ -import sys -import signal - from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.db.models import get_app, get_apps @@ -203,7 +200,7 @@ def dependency_ordered(test_databases, dependencies): deferred = [] while test_databases: - signature, aliases = test_databases.pop() + signature, (db_name, aliases) = test_databases.pop() dependencies_satisfied = True for alias in aliases: if alias in dependencies: @@ -217,10 +214,10 @@ def dependency_ordered(test_databases, dependencies): resolved_databases.add(alias) if dependencies_satisfied: - ordered_test_databases.append((signature, aliases)) + ordered_test_databases.append((signature, (db_name, aliases))) changed = True else: - deferred.append((signature, aliases)) + deferred.append((signature, (db_name, aliases))) if not changed: raise ImproperlyConfigured("Circular dependency in TEST_DEPENDENCIES") @@ -276,12 +273,11 @@ class DjangoTestSuiteRunner(object): # Store a tuple with DB parameters that uniquely identify it. # If we have two aliases with the same values for that tuple, # we only need to create the test database once. - test_databases.setdefault(( - connection.settings_dict['HOST'], - connection.settings_dict['PORT'], - connection.settings_dict['ENGINE'], - connection.settings_dict['NAME'], - ), []).append(alias) + item = test_databases.setdefault( + connection.creation.test_db_signature(), + (connection.settings_dict['NAME'], []) + ) + item[1].append(alias) if 'TEST_DEPENDENCIES' in connection.settings_dict: dependencies[alias] = connection.settings_dict['TEST_DEPENDENCIES'] @@ -292,7 +288,7 @@ class DjangoTestSuiteRunner(object): # Second pass -- actually create the databases. old_names = [] mirrors = [] - for (host, port, engine, db_name), aliases in dependency_ordered(test_databases.items(), dependencies): + for signature, (db_name, aliases) in dependency_ordered(test_databases.items(), dependencies): # Actually create the database for the first connection connection = connections[aliases[0]] old_names.append((connection, db_name, True)) |
