From c2c85663e2dd06c9ed9c9ec2d02202d6d668d7f0 Mon Sep 17 00:00:00 2001 From: Benjy Weinberger Date: Wed, 9 Jan 2019 10:58:25 -0500 Subject: [PATCH] Fixed #30087 -- Tested error handling for empty 'default' database. --- tests/db_utils/tests.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/db_utils/tests.py b/tests/db_utils/tests.py index 4e35e6bb8b..a6cfb43667 100644 --- a/tests/db_utils/tests.py +++ b/tests/db_utils/tests.py @@ -10,8 +10,18 @@ from django.test import SimpleTestCase, TestCase class ConnectionHandlerTests(SimpleTestCase): 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) self.assertEqual(conns[DEFAULT_DB_ALIAS].settings_dict['ENGINE'], 'django.db.backends.dummy') msg = (