summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomasz Kontusz <tomasz.kontusz@gmail.com>2015-06-03 17:05:03 +0200
committerTim Graham <timograham@gmail.com>2015-06-06 11:45:22 -0400
commitc2b4967e76fd671e6199e4dd54d2a2c1f096b8eb (patch)
tree9c0ca1cbcb89dba38a695fa323d563cb6c38de9c
parente5033dcbba4f040feae546345b0760efe7a46fb6 (diff)
Fixed ImportError message in utils.module_loading.import_string()
-rw-r--r--django/utils/module_loading.py2
-rw-r--r--tests/utils_tests/test_module_loading.py4
2 files changed, 4 insertions, 2 deletions
diff --git a/django/utils/module_loading.py b/django/utils/module_loading.py
index 5dc3aefe75..c42d208178 100644
--- a/django/utils/module_loading.py
+++ b/django/utils/module_loading.py
@@ -23,7 +23,7 @@ def import_string(dotted_path):
return getattr(module, class_name)
except AttributeError:
msg = 'Module "%s" does not define a "%s" attribute/class' % (
- dotted_path, class_name)
+ module_path, class_name)
six.reraise(ImportError, ImportError(msg), sys.exc_info()[2])
diff --git a/tests/utils_tests/test_module_loading.py b/tests/utils_tests/test_module_loading.py
index 8d600cb6f0..fb9ccbf5d6 100644
--- a/tests/utils_tests/test_module_loading.py
+++ b/tests/utils_tests/test_module_loading.py
@@ -115,7 +115,9 @@ class ModuleImportTestCase(unittest.TestCase):
# Test exceptions raised
self.assertRaises(ImportError, import_string, 'no_dots_in_path')
- self.assertRaises(ImportError, import_string, 'utils_tests.unexistent')
+ msg = 'Module "utils_tests" does not define a "unexistent" attribute'
+ with six.assertRaisesRegex(self, ImportError, msg):
+ import_string('utils_tests.unexistent')
@modify_settings(INSTALLED_APPS={'append': 'utils_tests.test_module'})