Ticket #16885: 16885_fix.diff

File 16885_fix.diff, 2.1 KB (added by Michael, 10 years ago)

Proposed fix + unittest

  • django/db/backends/creation.py

    diff --git a/django/db/backends/creation.py b/django/db/backends/creation.py
    index f03df5d..47ab578 100644
    a b import sys 
    22import time
    33
    44from django.conf import settings
     5from django.db import connections
    56
    67# The prefix to put on the default database name when creating
    78# the test database.
    class BaseDatabaseCreation(object): 
    231232        # Confirm the feature set of the test database
    232233        self.connection.features.confirm()
    233234
     235        # Also confirm the features for all mirrors of the test database.
     236        for conn in connections.all():
     237            mirror = connections.databases[conn.alias].get('TEST_MIRROR')
     238            if mirror and mirror == self.connection.alias:
     239                conn.features.confirm()
     240
    234241        # Report syncdb messages at one level lower than that requested.
    235242        # This ensures we don't get flooded with messages during testing
    236243        # (unless you really ask to be flooded)
  • tests/modeltests/transactions/tests.py

    diff --git a/tests/modeltests/transactions/tests.py b/tests/modeltests/transactions/tests.py
    index ed416e2..d358ade 100644
    a b class TransactionTests(TransactionTestCase): 
    160160            using_manually_managed_mistake
    161161        )
    162162
     163    def test_mirror_features(self):
     164        from django.conf import settings
     165        from django.db import connections
     166        from django.db.backends.creation import BaseDatabaseCreation
     167
     168        settings.DATABASES['other']['TEST_MIRROR'] = 'default'
     169
     170        class DummyDatabaseCreation(BaseDatabaseCreation):
     171            def _create_test_db(self, *args, **kwargs):
     172                pass
     173
     174        creator = DummyDatabaseCreation(connections['default'])
     175        creator.create_test_db()
     176
     177        self.assertTrue(connections['default'].features.supports_transactions)
     178        self.assertTrue(connections['other'].features.supports_transactions)
     179
     180        del settings.DATABASES['other']['TEST_MIRROR']
    163181
    164182class TransactionRollbackTests(TransactionTestCase):
    165183    def execute_bad_sql(self):
Back to Top