summaryrefslogtreecommitdiff
path: root/tests/template_backends
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2016-12-15 09:32:46 -0500
committerGitHub <noreply@github.com>2016-12-15 09:32:46 -0500
commit412997f8baff8df934709b9520c9863d629c687f (patch)
tree325977c3b8e39eb6219ee31ddd9b12651ae6f87b /tests/template_backends
parente36a9d3fd1fc8b3ef93b5baf054e41786fa2409f (diff)
downloaddjango-412997f8baff8df934709b9520c9863d629c687f.tar.gz
Used assertRaisesMessage() in template_backends tests.
Diffstat (limited to 'tests/template_backends')
-rw-r--r--tests/template_backends/test_utils.py31
1 files changed, 16 insertions, 15 deletions
diff --git a/tests/template_backends/test_utils.py b/tests/template_backends/test_utils.py
index c3eb6577a0..d1f3aaa793 100644
--- a/tests/template_backends/test_utils.py
+++ b/tests/template_backends/test_utils.py
@@ -3,20 +3,17 @@ from django.template import engines
from django.test import SimpleTestCase, override_settings
-class TemplateStringsTests(SimpleTestCase):
+class TemplateUtilsTests(SimpleTestCase):
- @override_settings(TEMPLATES=[{
- 'BACKEND': 'raise.import.error',
- }])
+ @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.
+ Failing to import a backend keeps raising the original import error
+ (#24265).
"""
- with self.assertRaises(ImportError):
+ with self.assertRaisesRegex(ImportError, "No module named '?raise"):
engines.all()
- with self.assertRaises(ImportError):
+ with self.assertRaisesRegex(ImportError, "No module named '?raise"):
engines.all()
@override_settings(TEMPLATES=[{
@@ -27,13 +24,13 @@ class TemplateStringsTests(SimpleTestCase):
}])
def test_backend_improperly_configured(self):
"""
- Failing to initialize a backend keeps raising the original exception.
-
- Regression test for #24265.
+ Failing to initialize a backend keeps raising the original exception
+ (#24265).
"""
- with self.assertRaises(ImproperlyConfigured):
+ msg = 'app_dirs must not be set when loaders is defined.'
+ with self.assertRaisesMessage(ImproperlyConfigured, msg):
engines.all()
- with self.assertRaises(ImproperlyConfigured):
+ with self.assertRaisesMessage(ImproperlyConfigured, msg):
engines.all()
@override_settings(TEMPLATES=[{
@@ -42,5 +39,9 @@ class TemplateStringsTests(SimpleTestCase):
'BACKEND': 'django.template.backends.django.DjangoTemplates',
}])
def test_backend_names_must_be_unique(self):
- with self.assertRaises(ImproperlyConfigured):
+ msg = (
+ "Template engine aliases aren't unique, duplicates: django. Set "
+ "a unique NAME for each engine in settings.TEMPLATES."
+ )
+ with self.assertRaisesMessage(ImproperlyConfigured, msg):
engines.all()