summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAndrei Kulakov <andrei.avk@gmail.com>2015-03-12 12:17:15 -0400
committerTim Graham <timograham@gmail.com>2015-03-25 17:56:59 -0400
commite2bfcab065fef4f1c2f32195c74f054991c33151 (patch)
tree4c43a0ae31f141c88a7d2aeea22348e6049037e4 /tests
parent7a75ed1a4fdf043064f0cce393bb93b698794978 (diff)
Fixed #24394 -- Allowed running tests with empty default dictionary.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_runner/tests.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/tests/test_runner/tests.py b/tests/test_runner/tests.py
index 46fac052a9..a9ae782f86 100644
--- a/tests/test_runner/tests.py
+++ b/tests/test_runner/tests.py
@@ -13,7 +13,7 @@ from django.core.exceptions import ImproperlyConfigured
from django.core.management import call_command
from django.db.backends.dummy.base import DatabaseCreation
from django.test import (
- TestCase, TransactionTestCase, mock, skipUnlessDBFeature,
+ TestCase, TransactionTestCase, mock, skipUnlessDBFeature, testcases,
)
from django.test.runner import DiscoverRunner, dependency_ordered
from django.test.testcases import connections_support_transactions
@@ -404,3 +404,18 @@ class AutoIncrementResetTest(TransactionTestCase):
def test_autoincrement_reset2(self):
p = Person.objects.create(first_name='Jack', last_name='Smith')
self.assertEqual(p.pk, 1)
+
+
+class EmptyDefaultDatabaseTest(unittest.TestCase):
+ def test_empty_default_database(self):
+ """
+ Test that 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')
+ try:
+ connections_support_transactions()
+ except Exception as e:
+ self.fail("connections_support_transactions() unexpectedly raised an error: %s" % e)