Fixed #32197 -- Improved error message when loading a database backend fails.
This commit is contained in:
parent
464a4c0c59
commit
4cce1d13cf
|
@ -120,8 +120,10 @@ def load_backend(backend_name):
|
|||
if backend_name not in ['django.db.backends.%s' % b for b in builtin_backends]:
|
||||
backend_reprs = map(repr, sorted(builtin_backends))
|
||||
raise ImproperlyConfigured(
|
||||
"%r isn't an available database backend.\n"
|
||||
"Try using 'django.db.backends.XXX', where XXX is one of:\n"
|
||||
"%r isn't an available database backend or couldn't be "
|
||||
"imported. Check the above exception. To use one of the "
|
||||
"built-in backends, use 'django.db.backends.XXX', where XXX "
|
||||
"is one of:\n"
|
||||
" %s" % (backend_name, ", ".join(backend_reprs))
|
||||
) from e_user
|
||||
else:
|
||||
|
|
|
@ -57,8 +57,9 @@ class LoadBackendTests(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"
|
||||
"'foo' isn't an available database backend or couldn't be "
|
||||
"imported. Check the above exception. To use one of the built-in "
|
||||
"backends, use 'django.db.backends.XXX', where XXX is one of:\n"
|
||||
" 'mysql', 'oracle', 'postgresql', 'sqlite3'"
|
||||
)
|
||||
with self.assertRaisesMessage(ImproperlyConfigured, msg) as cm:
|
||||
|
|
Loading…
Reference in New Issue