mirror of https://github.com/django/django.git
[1.5.x] Fixed #19940 -- Made test.runner.setup_databases properly handle aliases for defau
Thanks simonpercivall.
Backport of 2cbd579efe
from master.
This commit is contained in:
parent
25d987b21e
commit
95aa2182b7
|
@ -273,6 +273,7 @@ class DjangoTestSuiteRunner(object):
|
|||
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']:
|
||||
|
@ -294,7 +295,7 @@ class DjangoTestSuiteRunner(object):
|
|||
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])
|
||||
|
||||
|
|
|
@ -285,6 +285,31 @@ class DummyBackendTest(unittest.TestCase):
|
|||
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 = DjangoTestSuiteRunner(verbosity=0)
|
||||
old_db_connections = db.connections
|
||||
try:
|
||||
db.connections = db.ConnectionHandler({
|
||||
'default': {
|
||||
'NAME': 'dummy'
|
||||
},
|
||||
'aliased': {
|
||||
'NAME': 'dummy'
|
||||
}
|
||||
})
|
||||
old_config = runner.setup_databases()
|
||||
runner.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):
|
||||
|
|
Loading…
Reference in New Issue