1
0
mirror of https://github.com/django/django.git synced 2024-12-23 01:25:58 +00:00

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:
Jacob Walls 2020-12-27 10:23:16 -05:00 committed by Mariusz Felisiak
parent 429d089d0a
commit 89fc144ded
2 changed files with 3 additions and 2 deletions

View File

@ -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]

View File

@ -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({