Ticket #19940: setup_databases_head.patch

File setup_databases_head.patch, 2.2 KB (added by Simon Percivall, 11 years ago)
  • django/test/runner.py

    diff --git a/django/test/runner.py b/django/test/runner.py
    index 709b685..a2fbafb 100644
    a b def setup_databases(verbosity, interactive, **kwargs):  
    238238    mirrored_aliases = {}
    239239    test_databases = {}
    240240    dependencies = {}
     241    default_sig = connections[DEFAULT_DB_ALIAS].creation.test_db_signature()
    241242    for alias in connections:
    242243        connection = connections[alias]
    243244        if connection.settings_dict['TEST_MIRROR']:
    def setup_databases(verbosity, interactive, **kwargs):  
    259260                dependencies[alias] = (
    260261                    connection.settings_dict['TEST_DEPENDENCIES'])
    261262            else:
    262                 if alias != DEFAULT_DB_ALIAS:
     263                if alias != DEFAULT_DB_ALIAS and not connection.creation.test_db_signature() == default_sig:
    263264                    dependencies[alias] = connection.settings_dict.get(
    264265                        'TEST_DEPENDENCIES', [DEFAULT_DB_ALIAS])
    265266
  • tests/test_runner/tests.py

    diff --git a/tests/test_runner/tests.py b/tests/test_runner/tests.py
    index 4e9e44b..0c7c966 100644
    a b class DummyBackendTest(unittest.TestCase):  
    291291            db.connections = old_db_connections
    292292
    293293
     294class AliasedDefaultTestSetupTest(unittest.TestCase):
     295    def test_setup_aliased_default_database(self):
     296        """
     297        Test that setup_datebases() doesn't fail when 'default' is aliased
     298        """
     299        runner_instance = runner.DiscoverRunner(verbosity=0)
     300        old_db_connections = db.connections
     301        try:
     302            db.connections = db.ConnectionHandler({
     303                'default': {
     304                    'NAME': 'dummy'
     305                },
     306                'aliased': {
     307                    'NAME': 'dummy'
     308                }
     309            })
     310            old_config = runner_instance.setup_databases()
     311            runner_instance.teardown_databases(old_config)
     312        except Exception as e:
     313            self.fail("setup_databases/teardown_databases unexpectedly raised "
     314                      "an error: %s" % e)
     315        finally:
     316            db.connections = old_db_connections
     317
     318
    294319class DeprecationDisplayTest(AdminScriptTestCase):
    295320    # tests for 19546
    296321    def setUp(self):
Back to Top