summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2015-07-17 08:19:40 -0400
committerTim Graham <timograham@gmail.com>2015-07-17 08:21:43 -0400
commit28ee511b7e58edb6c0e4fcf3412dd40c6f60eb33 (patch)
tree92d3ab0042aef03421da628e6dd9e50fb320d69e
parent2f6bdab1597ee42b36752bf9f624d3386e951379 (diff)
Fixed db.utils.load_backend() on non-ASCII paths.
-rw-r--r--django/db/utils.py4
-rw-r--r--tests/backends/test_utils.py7
2 files changed, 5 insertions, 6 deletions
diff --git a/django/db/utils.py b/django/db/utils.py
index 20314495e4..64d44a715b 100644
--- a/django/db/utils.py
+++ b/django/db/utils.py
@@ -8,7 +8,7 @@ from threading import local
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.utils import six
-from django.utils._os import upath
+from django.utils._os import npath, upath
from django.utils.deprecation import RemovedInDjango110Warning
from django.utils.functional import cached_property
from django.utils.module_loading import import_string
@@ -113,7 +113,7 @@ def load_backend(backend_name):
backend_dir = os.path.join(os.path.dirname(upath(__file__)), 'backends')
try:
builtin_backends = [
- name for _, name, ispkg in pkgutil.iter_modules([backend_dir])
+ name for _, name, ispkg in pkgutil.iter_modules([npath(backend_dir)])
if ispkg and name not in {'base', 'dummy'}]
except EnvironmentError:
builtin_backends = []
diff --git a/tests/backends/test_utils.py b/tests/backends/test_utils.py
index 40a9c7b59c..beec31d2f5 100644
--- a/tests/backends/test_utils.py
+++ b/tests/backends/test_utils.py
@@ -1,17 +1,16 @@
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(
+ msg = (
"'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"
+ " 'mysql', 'oracle', 'postgresql_psycopg2', 'sqlite3'\n"
+ "Error was: No module named %s"
) % "foo.base" if six.PY2 else "'foo'"
with self.assertRaisesMessage(ImproperlyConfigured, msg):
load_backend('foo')