mirror of
https://github.com/django/django.git
synced 2025-08-31 15:57:45 +00:00
Fixed #24265 -- Preserved template backend loading exceptions.
If importing or initializing a template backend fails, attempting to access this template backend again must raise the same exception.
This commit is contained in:
parent
27f9ff459b
commit
44ad691558
2 changed files with 41 additions and 0 deletions
37
tests/template_backends/test_utils.py
Normal file
37
tests/template_backends/test_utils.py
Normal file
|
@ -0,0 +1,37 @@
|
|||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.template import engines
|
||||
from django.test import SimpleTestCase, override_settings
|
||||
|
||||
|
||||
class TemplateStringsTests(SimpleTestCase):
|
||||
|
||||
@override_settings(TEMPLATES=[{
|
||||
'BACKEND': 'raise.import.error',
|
||||
}])
|
||||
def test_backend_import_error(self):
|
||||
"""
|
||||
Failing to import a backend keeps raising the original import error.
|
||||
|
||||
Regression test for #24265.
|
||||
"""
|
||||
with self.assertRaises(ImportError):
|
||||
engines.all()
|
||||
with self.assertRaises(ImportError):
|
||||
engines.all()
|
||||
|
||||
@override_settings(TEMPLATES=[{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
# Incorrect: APP_DIRS and loaders are mutually incompatible.
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {'loaders': []},
|
||||
}])
|
||||
def test_backend_improperly_configured(self):
|
||||
"""
|
||||
Failing to initialize a backend keeps raising the original exception.
|
||||
|
||||
Regression test for #24265.
|
||||
"""
|
||||
with self.assertRaises(ImproperlyConfigured):
|
||||
engines.all()
|
||||
with self.assertRaises(ImproperlyConfigured):
|
||||
engines.all()
|
Loading…
Add table
Add a link
Reference in a new issue