Ticket #15029: 15029.diff

File 15029.diff, 6.3 KB (added by Ramiro Morales, 13 years ago)
  • django/db/backends/creation.py

    diff --git a/django/db/backends/creation.py b/django/db/backends/creation.py
    a b  
    462462    def sql_table_creation_suffix(self):
    463463        "SQL to append to the end of the test table creation statements"
    464464        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        )
  • django/db/backends/oracle/creation.py

    diff --git a/django/db/backends/oracle/creation.py b/django/db/backends/oracle/creation.py
    a b  
    259259        names as handled by Django haven't real counterparts in Oracle.
    260260        """
    261261        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        )
  • django/test/simple.py

    diff --git a/django/test/simple.py b/django/test/simple.py
    a b  
    1 import sys
    2 import signal
    3 
    41from django.conf import settings
    52from django.core.exceptions import ImproperlyConfigured
    63from django.db.models import get_app, get_apps
     
    203200        deferred = []
    204201
    205202        while test_databases:
    206             signature, aliases = test_databases.pop()
     203            signature, (db_name, aliases) = test_databases.pop()
    207204            dependencies_satisfied = True
    208205            for alias in aliases:
    209206                if alias in dependencies:
     
    217214                    resolved_databases.add(alias)
    218215
    219216            if dependencies_satisfied:
    220                 ordered_test_databases.append((signature, aliases))
     217                ordered_test_databases.append((signature, (db_name, aliases)))
    221218                changed = True
    222219            else:
    223                 deferred.append((signature, aliases))
     220                deferred.append((signature, (db_name, aliases)))
    224221
    225222        if not changed:
    226223            raise ImproperlyConfigured("Circular dependency in TEST_DEPENDENCIES")
     
    276273                # Store a tuple with DB parameters that uniquely identify it.
    277274                # If we have two aliases with the same values for that tuple,
    278275                # 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)
    285281
    286282                if 'TEST_DEPENDENCIES' in connection.settings_dict:
    287283                    dependencies[alias] = connection.settings_dict['TEST_DEPENDENCIES']
     
    292288        # Second pass -- actually create the databases.
    293289        old_names = []
    294290        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):
    296292            # Actually create the database for the first connection
    297293            connection = connections[aliases[0]]
    298294            old_names.append((connection, db_name, True))
  • tests/regressiontests/test_runner/tests.py

    diff --git a/tests/regressiontests/test_runner/tests.py b/tests/regressiontests/test_runner/tests.py
    a b  
    3333
    3434    def test_simple_dependencies(self):
    3535        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'])),
    3939        ]
    4040        dependencies = {
    4141            'alpha': ['charlie'],
     
    4343        }
    4444
    4545        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]
    4747
    4848        self.assertIn('s1', ordered_sigs)
    4949        self.assertIn('s2', ordered_sigs)
     
    5353
    5454    def test_chained_dependencies(self):
    5555        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'])),
    5959        ]
    6060        dependencies = {
    6161            'alpha': ['bravo'],
     
    6363        }
    6464
    6565        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]
    6767
    6868        self.assertIn('s1', ordered_sigs)
    6969        self.assertIn('s2', ordered_sigs)
     
    7878
    7979    def test_multiple_dependencies(self):
    8080        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'])),
    8585        ]
    8686        dependencies = {
    8787            'alpha': ['bravo','delta'],
     
    108108
    109109    def test_circular_dependencies(self):
    110110        raw = [
    111             ('s1', ['alpha']),
    112             ('s2', ['bravo']),
     111            ('s1', ('s1_db', ['alpha'])),
     112            ('s2', ('s2_db', ['bravo'])),
    113113        ]
    114114        dependencies = {
    115115            'bravo': ['alpha'],
Back to Top