Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[1.6.x] Fixed #19940 -- Made test.runner.setup_databases properly han…

…dle aliases for default db.

Thanks simonpercivall.

Backport of 2cbd579 from master.
  • Loading branch information...
commit d14db25feec73690b1cd52b3f8b83e3e38deb23b 1 parent 541a30c
@timgraham timgraham authored
Showing with 27 additions and 1 deletion.
  1. +2 −1  django/test/runner.py
  2. +25 −0 tests/test_runner/tests.py
View
3  django/test/runner.py
@@ -238,6 +238,7 @@ def setup_databases(verbosity, interactive, **kwargs):
mirrored_aliases = {}
test_databases = {}
dependencies = {}
+ default_sig = connections[DEFAULT_DB_ALIAS].creation.test_db_signature()
for alias in connections:
connection = connections[alias]
if connection.settings_dict['TEST_MIRROR']:
@@ -259,7 +260,7 @@ def setup_databases(verbosity, interactive, **kwargs):
dependencies[alias] = (
connection.settings_dict['TEST_DEPENDENCIES'])
else:
- if alias != DEFAULT_DB_ALIAS:
+ if alias != DEFAULT_DB_ALIAS and connection.creation.test_db_signature() != default_sig:
dependencies[alias] = connection.settings_dict.get(
'TEST_DEPENDENCIES', [DEFAULT_DB_ALIAS])
View
25 tests/test_runner/tests.py
@@ -290,6 +290,31 @@ def test_setup_databases(self):
db.connections = old_db_connections
+class AliasedDefaultTestSetupTest(unittest.TestCase):
+ def test_setup_aliased_default_database(self):
+ """
+ Test that setup_datebases() doesn't fail when 'default' is aliased
+ """
+ runner_instance = runner.DiscoverRunner(verbosity=0)
+ old_db_connections = db.connections
+ try:
+ db.connections = db.ConnectionHandler({
+ 'default': {
+ 'NAME': 'dummy'
+ },
+ 'aliased': {
+ 'NAME': 'dummy'
+ }
+ })
+ old_config = runner_instance.setup_databases()
+ runner_instance.teardown_databases(old_config)
+ except Exception as e:
+ self.fail("setup_databases/teardown_databases unexpectedly raised "
+ "an error: %s" % e)
+ finally:
+ db.connections = old_db_connections
+
+
class DeprecationDisplayTest(AdminScriptTestCase):
# tests for 19546
def setUp(self):
Please sign in to comment.
Something went wrong with that request. Please try again.