summaryrefslogtreecommitdiff
path: root/tests/db_utils
diff options
context:
space:
mode:
authordjango-bot <ops@djangoproject.com>2022-02-03 20:24:19 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-02-07 20:37:05 +0100
commit9c19aff7c7561e3a82978a272ecdaad40dda5c00 (patch)
treef0506b668a013d0063e5fba3dbf4863b466713ba /tests/db_utils
parentf68fa8b45dfac545cfc4111d4e52804c86db68d3 (diff)
downloaddjango-9c19aff7c7561e3a82978a272ecdaad40dda5c00.tar.gz
Refs #33476 -- Reformatted code with Black.
Diffstat (limited to 'tests/db_utils')
-rw-r--r--tests/db_utils/tests.py51
1 files changed, 28 insertions, 23 deletions
diff --git a/tests/db_utils/tests.py b/tests/db_utils/tests.py
index 7612c6f2fa..99b58d0b8a 100644
--- a/tests/db_utils/tests.py
+++ b/tests/db_utils/tests.py
@@ -9,7 +9,6 @@ from django.utils.connection import ConnectionDoesNotExist
class ConnectionHandlerTests(SimpleTestCase):
-
def test_connection_handler_no_databases(self):
"""
Empty DATABASES and empty 'default' settings default to the dummy
@@ -17,56 +16,63 @@ class ConnectionHandlerTests(SimpleTestCase):
"""
for DATABASES in (
{}, # Empty DATABASES setting.
- {'default': {}}, # Empty 'default' database.
+ {"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')
+ self.assertEqual(
+ conns[DEFAULT_DB_ALIAS].settings_dict["ENGINE"], "django.db.backends.dummy"
+ )
msg = (
- 'settings.DATABASES is improperly configured. Please supply the '
- 'ENGINE value. Check settings documentation for more details.'
+ "settings.DATABASES is improperly configured. Please supply the "
+ "ENGINE value. Check settings documentation for more details."
)
with self.assertRaisesMessage(ImproperlyConfigured, msg):
conns[DEFAULT_DB_ALIAS].ensure_connection()
def test_no_default_database(self):
- DATABASES = {'other': {}}
+ DATABASES = {"other": {}}
conns = ConnectionHandler(DATABASES)
msg = "You must define a 'default' database."
with self.assertRaisesMessage(ImproperlyConfigured, msg):
- conns['other'].ensure_connection()
+ conns["other"].ensure_connection()
def test_nonexistent_alias(self):
msg = "The connection 'nonexistent' doesn't exist."
- conns = ConnectionHandler({
- DEFAULT_DB_ALIAS: {'ENGINE': 'django.db.backends.dummy'},
- })
+ conns = ConnectionHandler(
+ {
+ DEFAULT_DB_ALIAS: {"ENGINE": "django.db.backends.dummy"},
+ }
+ )
with self.assertRaisesMessage(ConnectionDoesNotExist, msg):
- conns['nonexistent']
+ conns["nonexistent"]
def test_ensure_defaults_nonexistent_alias(self):
msg = "The connection 'nonexistent' doesn't exist."
- conns = ConnectionHandler({
- DEFAULT_DB_ALIAS: {'ENGINE': 'django.db.backends.dummy'},
- })
+ conns = ConnectionHandler(
+ {
+ DEFAULT_DB_ALIAS: {"ENGINE": "django.db.backends.dummy"},
+ }
+ )
with self.assertRaisesMessage(ConnectionDoesNotExist, msg):
- conns.ensure_defaults('nonexistent')
+ conns.ensure_defaults("nonexistent")
def test_prepare_test_settings_nonexistent_alias(self):
msg = "The connection 'nonexistent' doesn't exist."
- conns = ConnectionHandler({
- DEFAULT_DB_ALIAS: {'ENGINE': 'django.db.backends.dummy'},
- })
+ conns = ConnectionHandler(
+ {
+ DEFAULT_DB_ALIAS: {"ENGINE": "django.db.backends.dummy"},
+ }
+ )
with self.assertRaisesMessage(ConnectionDoesNotExist, msg):
- conns.prepare_test_settings('nonexistent')
+ conns.prepare_test_settings("nonexistent")
class DatabaseErrorWrapperTests(TestCase):
-
- @unittest.skipUnless(connection.vendor == 'postgresql', 'PostgreSQL test')
+ @unittest.skipUnless(connection.vendor == "postgresql", "PostgreSQL test")
def test_reraising_backend_specific_database_exception(self):
with connection.cursor() as cursor:
msg = 'table "X" does not exist'
@@ -79,7 +85,6 @@ class DatabaseErrorWrapperTests(TestCase):
class LoadBackendTests(SimpleTestCase):
-
def test_load_backend_invalid_name(self):
msg = (
"'foo' isn't an available database backend or couldn't be "
@@ -88,5 +93,5 @@ class LoadBackendTests(SimpleTestCase):
" 'mysql', 'oracle', 'postgresql', 'sqlite3'"
)
with self.assertRaisesMessage(ImproperlyConfigured, msg) as cm:
- load_backend('foo')
+ load_backend("foo")
self.assertEqual(str(cm.exception.__cause__), "No module named 'foo'")