1
0
mirror of https://github.com/django/django.git synced 2024-12-23 01:25:58 +00:00

Fixed #30087 -- Tested error handling for empty 'default' database.

This commit is contained in:
Benjy Weinberger 2019-01-09 10:58:25 -05:00 committed by Tim Graham
parent a35d2a4510
commit c2c85663e2

View File

@ -10,8 +10,18 @@ from django.test import SimpleTestCase, TestCase
class ConnectionHandlerTests(SimpleTestCase): class ConnectionHandlerTests(SimpleTestCase):
def test_connection_handler_no_databases(self): def test_connection_handler_no_databases(self):
"""Empty DATABASES setting defaults to the dummy backend.""" """
DATABASES = {} Empty DATABASES and empty 'default' settings default to the dummy
backend.
"""
for DATABASES in (
{}, # Empty DATABASES setting.
{'default': {}}, # Empty 'default' database.
):
with self.subTest(DATABASES=DATABASES):
self.assertImproperlyConfigured(DATABASES)
def assertImproperlyConfigured(self, DATABASES):
conns = ConnectionHandler(DATABASES) conns = ConnectionHandler(DATABASES)
self.assertEqual(conns[DEFAULT_DB_ALIAS].settings_dict['ENGINE'], 'django.db.backends.dummy') self.assertEqual(conns[DEFAULT_DB_ALIAS].settings_dict['ENGINE'], 'django.db.backends.dummy')
msg = ( msg = (