Fixed isolation of test_runner.EmptyDefaultDatabaseTest.

This fixes test_runner.test_debug_sql.TestDebugSQL.
test_setupclass_exception when run in reverse.
This commit is contained in:
Mariusz Felisiak 2020-12-10 18:48:07 +01:00 committed by GitHub
parent 275dd4ebba
commit 00a1d42bf0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 5 deletions

View File

@ -11,7 +11,7 @@ from django.conf import settings
from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import ImproperlyConfigured
from django.core.management import call_command from django.core.management import call_command
from django.core.management.base import SystemCheckError 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.runner import DiscoverRunner
from django.test.testcases import connections_support_transactions from django.test.testcases import connections_support_transactions
from django.test.utils import captured_stderr, dependency_ordered 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 An empty default database in settings does not raise an ImproperlyConfigured
error when running a unit test that does not use a database. error when running a unit test that does not use a database.
""" """
testcases.connections = db.ConnectionHandler({'default': {}}) tested_connections = db.ConnectionHandler({'default': {}})
connection = testcases.connections[db.utils.DEFAULT_DB_ALIAS] with mock.patch('django.db.connections', new=tested_connections):
self.assertEqual(connection.settings_dict['ENGINE'], 'django.db.backends.dummy') connection = tested_connections[db.utils.DEFAULT_DB_ALIAS]
connections_support_transactions() self.assertEqual(connection.settings_dict['ENGINE'], 'django.db.backends.dummy')
connections_support_transactions()
class RunTestsExceptionHandlingTests(unittest.TestCase): class RunTestsExceptionHandlingTests(unittest.TestCase):