test_utils.py 652 B

12345678910111213141516
  1. from django.core.exceptions import ImproperlyConfigured
  2. from django.db.utils import load_backend
  3. from django.test import SimpleTestCase
  4. from django.utils import six
  5. class TestLoadBackend(SimpleTestCase):
  6. def test_load_backend_invalid_name(self):
  7. msg = (
  8. "'foo' isn't an available database backend.\n"
  9. "Try using 'django.db.backends.XXX', where XXX is one of:\n"
  10. " 'mysql', 'oracle', 'postgresql', 'sqlite3'\n"
  11. "Error was: No module named %s"
  12. ) % "foo.base" if six.PY2 else "'foo'"
  13. with self.assertRaisesMessage(ImproperlyConfigured, msg):
  14. load_backend('foo')