2015-07-15 22:19:38 +08:00
|
|
|
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):
|
2015-07-17 20:19:40 +08:00
|
|
|
msg = (
|
2015-07-15 22:19:38 +08:00
|
|
|
"'foo' isn't an available database backend.\n"
|
|
|
|
"Try using 'django.db.backends.XXX', where XXX is one of:\n"
|
2017-01-24 21:33:26 +08:00
|
|
|
" 'mysql', 'oracle', 'postgresql', 'sqlite3'"
|
2016-12-01 18:38:01 +08:00
|
|
|
)
|
2017-01-24 21:33:26 +08:00
|
|
|
with self.assertRaisesMessage(ImproperlyConfigured, msg) as cm:
|
2015-07-15 22:19:38 +08:00
|
|
|
load_backend('foo')
|
2017-01-24 21:33:26 +08:00
|
|
|
self.assertEqual(str(cm.exception.__cause__), "No module named 'foo'")
|