diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-12-10 18:48:07 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-12-10 18:48:07 +0100 |
| commit | 00a1d42bf0d83ba4b329271433eb5e3fd0f704fe (patch) | |
| tree | a5c6d1b40e87ffe284fcf9d57b3e2e76cda13ac2 | |
| parent | 275dd4ebbabbbe758c7219a3d666953d5a7b072f (diff) | |
Fixed isolation of test_runner.EmptyDefaultDatabaseTest.
This fixes test_runner.test_debug_sql.TestDebugSQL.
test_setupclass_exception when run in reverse.
| -rw-r--r-- | tests/test_runner/tests.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/tests/test_runner/tests.py b/tests/test_runner/tests.py index e12ea3b11a..07c7836708 100644 --- a/tests/test_runner/tests.py +++ b/tests/test_runner/tests.py @@ -11,7 +11,7 @@ from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.core.management import call_command from django.core.management.base import SystemCheckError -from django.test import TransactionTestCase, skipUnlessDBFeature, testcases +from django.test import TransactionTestCase, skipUnlessDBFeature from django.test.runner import DiscoverRunner from django.test.testcases import connections_support_transactions from django.test.utils import captured_stderr, dependency_ordered @@ -413,10 +413,11 @@ class EmptyDefaultDatabaseTest(unittest.TestCase): An empty default database in settings does not raise an ImproperlyConfigured error when running a unit test that does not use a database. """ - testcases.connections = db.ConnectionHandler({'default': {}}) - connection = testcases.connections[db.utils.DEFAULT_DB_ALIAS] - self.assertEqual(connection.settings_dict['ENGINE'], 'django.db.backends.dummy') - connections_support_transactions() + tested_connections = db.ConnectionHandler({'default': {}}) + with mock.patch('django.db.connections', new=tested_connections): + connection = tested_connections[db.utils.DEFAULT_DB_ALIAS] + self.assertEqual(connection.settings_dict['ENGINE'], 'django.db.backends.dummy') + connections_support_transactions() class RunTestsExceptionHandlingTests(unittest.TestCase): |
