Loading django/db/utils.py +1 −1 Original line number Diff line number Diff line Loading @@ -114,7 +114,7 @@ def load_backend(backend_name): try: builtin_backends = [ name for _, name, ispkg in pkgutil.iter_modules([backend_dir]) if ispkg and name != 'dummy'] if ispkg and name not in {'base', 'dummy'}] except EnvironmentError: builtin_backends = [] if backend_name not in ['django.db.backends.%s' % b for b in Loading tests/backends/test_utils.py 0 → 100644 +17 −0 Original line number Diff line number Diff line from django.core.exceptions import ImproperlyConfigured from django.db.utils import load_backend from django.test import SimpleTestCase from django.test.utils import str_prefix from django.utils import six class TestLoadBackend(SimpleTestCase): def test_load_backend_invalid_name(self): msg = str_prefix( "'foo' isn't an available database backend.\n" "Try using 'django.db.backends.XXX', where XXX is one of:\n" " %(_)s'mysql', %(_)s'oracle', %(_)s'postgresql_psycopg2', %(_)s'sqlite3'\n" "Error was: No module named %%s" ) % "foo.base" if six.PY2 else "'foo'" with self.assertRaisesMessage(ImproperlyConfigured, msg): load_backend('foo') Loading
django/db/utils.py +1 −1 Original line number Diff line number Diff line Loading @@ -114,7 +114,7 @@ def load_backend(backend_name): try: builtin_backends = [ name for _, name, ispkg in pkgutil.iter_modules([backend_dir]) if ispkg and name != 'dummy'] if ispkg and name not in {'base', 'dummy'}] except EnvironmentError: builtin_backends = [] if backend_name not in ['django.db.backends.%s' % b for b in Loading
tests/backends/test_utils.py 0 → 100644 +17 −0 Original line number Diff line number Diff line from django.core.exceptions import ImproperlyConfigured from django.db.utils import load_backend from django.test import SimpleTestCase from django.test.utils import str_prefix from django.utils import six class TestLoadBackend(SimpleTestCase): def test_load_backend_invalid_name(self): msg = str_prefix( "'foo' isn't an available database backend.\n" "Try using 'django.db.backends.XXX', where XXX is one of:\n" " %(_)s'mysql', %(_)s'oracle', %(_)s'postgresql_psycopg2', %(_)s'sqlite3'\n" "Error was: No module named %%s" ) % "foo.base" if six.PY2 else "'foo'" with self.assertRaisesMessage(ImproperlyConfigured, msg): load_backend('foo')