mirror of https://github.com/django/django.git
Fixed #27827 -- Used "raise from" when raising InvalidTemplateLibrary exceptions in get_package_libraries().
This change sets the __cause__ attribute to raised exceptions and makes small cleanups in error messages.
This commit is contained in:
parent
429d089d0a
commit
89fc144ded
|
@ -123,7 +123,7 @@ def get_package_libraries(pkg):
|
|||
raise InvalidTemplateLibrary(
|
||||
"Invalid template library specified. ImportError raised when "
|
||||
"trying to load '%s': %s" % (entry[1], e)
|
||||
)
|
||||
) from e
|
||||
|
||||
if hasattr(module, 'register'):
|
||||
yield entry[1]
|
||||
|
|
|
@ -104,13 +104,14 @@ class DjangoTemplatesTests(TemplateStringsTests):
|
|||
InvalidTemplateLibrary,
|
||||
"ImportError raised when trying to load "
|
||||
"'template_backends.apps.importerror.templatetags.broken_tags'"
|
||||
):
|
||||
) as cm:
|
||||
DjangoTemplates({
|
||||
'DIRS': [],
|
||||
'APP_DIRS': False,
|
||||
'NAME': 'django',
|
||||
'OPTIONS': {},
|
||||
})
|
||||
self.assertIsInstance(cm.exception.__cause__, ImportError)
|
||||
|
||||
def test_builtins_discovery(self):
|
||||
engine = DjangoTemplates({
|
||||
|
|
Loading…
Reference in New Issue