mirror of https://github.com/django/django.git
Moved an import to the toplevel.
This commit is contained in:
parent
6d1110f2f0
commit
c4bdf52005
|
@ -6,6 +6,7 @@ from unittest import TestSuite, defaultTestLoader
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.exceptions import ImproperlyConfigured
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
|
from django.db import DEFAULT_DB_ALIAS, connections
|
||||||
from django.test import SimpleTestCase, TestCase
|
from django.test import SimpleTestCase, TestCase
|
||||||
from django.test.utils import setup_test_environment, teardown_test_environment
|
from django.test.utils import setup_test_environment, teardown_test_environment
|
||||||
from django.utils.datastructures import OrderedSet
|
from django.utils.datastructures import OrderedSet
|
||||||
|
@ -321,8 +322,6 @@ def partition_suite(suite, classes, bins, reverse=False):
|
||||||
|
|
||||||
|
|
||||||
def setup_databases(verbosity, interactive, keepdb=False, debug_sql=False, **kwargs):
|
def setup_databases(verbosity, interactive, keepdb=False, debug_sql=False, **kwargs):
|
||||||
from django.db import connections, DEFAULT_DB_ALIAS
|
|
||||||
|
|
||||||
# First pass -- work out which databases actually need to be created,
|
# First pass -- work out which databases actually need to be created,
|
||||||
# and which ones are test mirrors or duplicate entries in DATABASES
|
# and which ones are test mirrors or duplicate entries in DATABASES
|
||||||
mirrored_aliases = {}
|
mirrored_aliases = {}
|
||||||
|
|
|
@ -240,7 +240,7 @@ class DummyBackendTest(unittest.TestCase):
|
||||||
Test that setup_databases() doesn't fail with dummy database backend.
|
Test that setup_databases() doesn't fail with dummy database backend.
|
||||||
"""
|
"""
|
||||||
tested_connections = db.ConnectionHandler({})
|
tested_connections = db.ConnectionHandler({})
|
||||||
with mock.patch('django.db.connections', new=tested_connections):
|
with mock.patch('django.test.runner.connections', new=tested_connections):
|
||||||
runner_instance = DiscoverRunner(verbosity=0)
|
runner_instance = DiscoverRunner(verbosity=0)
|
||||||
try:
|
try:
|
||||||
old_config = runner_instance.setup_databases()
|
old_config = runner_instance.setup_databases()
|
||||||
|
@ -263,7 +263,7 @@ class AliasedDefaultTestSetupTest(unittest.TestCase):
|
||||||
'NAME': 'dummy'
|
'NAME': 'dummy'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
with mock.patch('django.db.connections', new=tested_connections):
|
with mock.patch('django.test.runner.connections', new=tested_connections):
|
||||||
runner_instance = DiscoverRunner(verbosity=0)
|
runner_instance = DiscoverRunner(verbosity=0)
|
||||||
try:
|
try:
|
||||||
old_config = runner_instance.setup_databases()
|
old_config = runner_instance.setup_databases()
|
||||||
|
@ -291,7 +291,7 @@ class SetupDatabasesTests(unittest.TestCase):
|
||||||
})
|
})
|
||||||
|
|
||||||
with mock.patch('django.db.backends.dummy.base.DatabaseCreation') as mocked_db_creation:
|
with mock.patch('django.db.backends.dummy.base.DatabaseCreation') as mocked_db_creation:
|
||||||
with mock.patch('django.db.connections', new=tested_connections):
|
with mock.patch('django.test.runner.connections', new=tested_connections):
|
||||||
old_config = self.runner_instance.setup_databases()
|
old_config = self.runner_instance.setup_databases()
|
||||||
self.runner_instance.teardown_databases(old_config)
|
self.runner_instance.teardown_databases(old_config)
|
||||||
mocked_db_creation.return_value.destroy_test_db.assert_called_once_with('dbname', 0, False)
|
mocked_db_creation.return_value.destroy_test_db.assert_called_once_with('dbname', 0, False)
|
||||||
|
@ -316,7 +316,7 @@ class SetupDatabasesTests(unittest.TestCase):
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
with mock.patch('django.db.backends.dummy.base.DatabaseCreation') as mocked_db_creation:
|
with mock.patch('django.db.backends.dummy.base.DatabaseCreation') as mocked_db_creation:
|
||||||
with mock.patch('django.db.connections', new=tested_connections):
|
with mock.patch('django.test.runner.connections', new=tested_connections):
|
||||||
self.runner_instance.setup_databases()
|
self.runner_instance.setup_databases()
|
||||||
mocked_db_creation.return_value.create_test_db.assert_called_once_with(
|
mocked_db_creation.return_value.create_test_db.assert_called_once_with(
|
||||||
0, autoclobber=False, serialize=True, keepdb=False
|
0, autoclobber=False, serialize=True, keepdb=False
|
||||||
|
@ -330,7 +330,7 @@ class SetupDatabasesTests(unittest.TestCase):
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
with mock.patch('django.db.backends.dummy.base.DatabaseCreation') as mocked_db_creation:
|
with mock.patch('django.db.backends.dummy.base.DatabaseCreation') as mocked_db_creation:
|
||||||
with mock.patch('django.db.connections', new=tested_connections):
|
with mock.patch('django.test.runner.connections', new=tested_connections):
|
||||||
self.runner_instance.setup_databases()
|
self.runner_instance.setup_databases()
|
||||||
mocked_db_creation.return_value.create_test_db.assert_called_once_with(
|
mocked_db_creation.return_value.create_test_db.assert_called_once_with(
|
||||||
0, autoclobber=False, serialize=False, keepdb=False
|
0, autoclobber=False, serialize=False, keepdb=False
|
||||||
|
|
Loading…
Reference in New Issue