mirror of https://github.com/django/django.git
[1.8.x] Fixed ImportError message in utils.module_loading.import_string()
Backport of c2b4967e76
from master
This commit is contained in:
parent
66496c8403
commit
b62dc60c98
|
@ -29,7 +29,7 @@ def import_string(dotted_path):
|
||||||
return getattr(module, class_name)
|
return getattr(module, class_name)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
msg = 'Module "%s" does not define a "%s" attribute/class' % (
|
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])
|
six.reraise(ImportError, ImportError(msg), sys.exc_info()[2])
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -150,8 +150,10 @@ class ModuleImportTestCase(unittest.TestCase):
|
||||||
|
|
||||||
# Test exceptions raised
|
# Test exceptions raised
|
||||||
self.assertRaises(ImportError, import_string, 'no_dots_in_path')
|
self.assertRaises(ImportError, import_string, 'no_dots_in_path')
|
||||||
self.assertRaises(ImportError, import_string, 'utils_tests.unexistent')
|
|
||||||
self.assertRaises(ImportError, import_string, 'unexistent.path')
|
self.assertRaises(ImportError, import_string, 'unexistent.path')
|
||||||
|
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'})
|
@modify_settings(INSTALLED_APPS={'append': 'utils_tests.test_module'})
|
||||||
|
|
Loading…
Reference in New Issue