From c4bdf52005c1f03a47c4699b4682b98d00fd4a5b Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Sat, 5 Sep 2015 21:52:36 +0200 Subject: [PATCH] Moved an import to the toplevel. --- django/test/runner.py | 3 +-- tests/test_runner/tests.py | 10 +++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/django/test/runner.py b/django/test/runner.py index 99bc0e5c02..8bb3c6c6f7 100644 --- a/django/test/runner.py +++ b/django/test/runner.py @@ -6,6 +6,7 @@ from unittest import TestSuite, defaultTestLoader from django.conf import settings from django.core.exceptions import ImproperlyConfigured +from django.db import DEFAULT_DB_ALIAS, connections from django.test import SimpleTestCase, TestCase from django.test.utils import setup_test_environment, teardown_test_environment 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): - from django.db import connections, DEFAULT_DB_ALIAS - # First pass -- work out which databases actually need to be created, # and which ones are test mirrors or duplicate entries in DATABASES mirrored_aliases = {} diff --git a/tests/test_runner/tests.py b/tests/test_runner/tests.py index 3e47ee00f7..8e9991d654 100644 --- a/tests/test_runner/tests.py +++ b/tests/test_runner/tests.py @@ -240,7 +240,7 @@ class DummyBackendTest(unittest.TestCase): Test that setup_databases() doesn't fail with dummy database backend. """ 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) try: old_config = runner_instance.setup_databases() @@ -263,7 +263,7 @@ class AliasedDefaultTestSetupTest(unittest.TestCase): '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) try: 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.connections', new=tested_connections): + with mock.patch('django.test.runner.connections', new=tested_connections): old_config = self.runner_instance.setup_databases() self.runner_instance.teardown_databases(old_config) 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.connections', new=tested_connections): + with mock.patch('django.test.runner.connections', new=tested_connections): self.runner_instance.setup_databases() mocked_db_creation.return_value.create_test_db.assert_called_once_with( 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.connections', new=tested_connections): + with mock.patch('django.test.runner.connections', new=tested_connections): self.runner_instance.setup_databases() mocked_db_creation.return_value.create_test_db.assert_called_once_with( 0, autoclobber=False, serialize=False, keepdb=False