mirror of https://github.com/django/django.git
Used assertRaisesMessage() in template_backends tests.
This commit is contained in:
parent
e36a9d3fd1
commit
412997f8ba
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue