Ticket #19940: setup_databases.patch

File setup_databases.patch, 2.3 KB (added by Simon Percivall, 11 years ago)
  • django/test/simple.py

    diff --git a/django/test/simple.py b/django/test/simple.py
    index bf0219d..91df209 100644
    a b class DjangoTestSuiteRunner(object):  
    273273        mirrored_aliases = {}
    274274        test_databases = {}
    275275        dependencies = {}
     276        default_sig = connections[DEFAULT_DB_ALIAS].creation.test_db_signature()
    276277        for alias in connections:
    277278            connection = connections[alias]
    278279            if connection.settings_dict['TEST_MIRROR']:
    class DjangoTestSuiteRunner(object):  
    294295                    dependencies[alias] = (
    295296                        connection.settings_dict['TEST_DEPENDENCIES'])
    296297                else:
    297                     if alias != DEFAULT_DB_ALIAS:
     298                    if alias != DEFAULT_DB_ALIAS and not connection.creation.test_db_signature() == default_sig:
    298299                        dependencies[alias] = connection.settings_dict.get(
    299300                            'TEST_DEPENDENCIES', [DEFAULT_DB_ALIAS])
    300301
  • tests/regressiontests/test_runner/tests.py

    diff --git a/tests/regressiontests/test_runner/tests.py b/tests/regressiontests/test_runner/tests.py
    index b5e4a1d..48a8e09 100644
    a b class DummyBackendTest(unittest.TestCase):  
    285285            db.connections = old_db_connections
    286286
    287287
     288class AliasedDefaultTestSetupTest(unittest.TestCase):
     289    def test_setup_aliased_default_database(self):
     290        """
     291        Test that setup_datebases() doesn't fail when 'default' is aliased
     292        """
     293        runner = DjangoTestSuiteRunner(verbosity=0)
     294        old_db_connections = db.connections
     295        try:
     296            db.connections = db.ConnectionHandler({
     297                'default': {
     298                    'NAME': 'dummy'
     299                },
     300                'aliased': {
     301                    'NAME': 'dummy'
     302                }
     303            })
     304            old_config = runner.setup_databases()
     305            runner.teardown_databases(old_config)
     306        except Exception as e:
     307            self.fail("setup_databases/teardown_databases unexpectedly raised "
     308                      "an error: %s" % e)
     309        finally:
     310            db.connections = old_db_connections
     311
     312
    288313class DeprecationDisplayTest(AdminScriptTestCase):
    289314    # tests for 19546
    290315    def setUp(self):
Back to Top