1
0
mirror of https://github.com/django/django.git synced 2025-02-10 01:16:53 +00:00
django/tests/backends/test_utils.py
Tim Graham a87d6b69a7 Tidied djang.db.utils.load_backend().
Removed an unneeded EnvironmentError catching and used
"raise from exc" syntax.
2017-01-24 08:33:26 -05:00

16 lines
625 B
Python

from django.core.exceptions import ImproperlyConfigured
from django.db.utils import load_backend
from django.test import SimpleTestCase
class TestLoadBackend(SimpleTestCase):
def test_load_backend_invalid_name(self):
msg = (
"'foo' isn't an available database backend.\n"
"Try using 'django.db.backends.XXX', where XXX is one of:\n"
" 'mysql', 'oracle', 'postgresql', 'sqlite3'"
)
with self.assertRaisesMessage(ImproperlyConfigured, msg) as cm:
load_backend('foo')
self.assertEqual(str(cm.exception.__cause__), "No module named 'foo'")