diff options
author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2015-02-05 11:53:04 +0100 |
---|---|---|
committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2015-02-05 20:06:18 +0100 |
commit | 44ad691558c88ac54483030b2c8b749788c4600e (patch) | |
tree | ec2d4074acce238f63ce903e7c54546ee5476dd2 /tests/template_backends | |
parent | 27f9ff459b17ccce8177f454174232a6ec5a79e7 (diff) | |
download | django-44ad691558c88ac54483030b2c8b749788c4600e.tar.gz |
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.
Diffstat (limited to 'tests/template_backends')
-rw-r--r-- | tests/template_backends/test_utils.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/template_backends/test_utils.py b/tests/template_backends/test_utils.py new file mode 100644 index 0000000000..3d2de99015 --- /dev/null +++ b/tests/template_backends/test_utils.py @@ -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() |