mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #15053 -- Enabled recursive template loading.
This commit is contained in:
@@ -33,8 +33,12 @@ class TemplateLoaderTests(SimpleTestCase):
|
||||
self.assertEqual(template.render(), "Hello! (Django templates)\n")
|
||||
|
||||
def test_get_template_not_found(self):
|
||||
with self.assertRaises(TemplateDoesNotExist):
|
||||
with self.assertRaises(TemplateDoesNotExist) as e:
|
||||
get_template("template_loader/unknown.html")
|
||||
self.assertEqual(
|
||||
e.exception.tried[-1][0].template_name,
|
||||
'template_loader/unknown.html',
|
||||
)
|
||||
|
||||
def test_select_template_first_engine(self):
|
||||
template = select_template(["template_loader/unknown.html",
|
||||
@@ -56,9 +60,17 @@ class TemplateLoaderTests(SimpleTestCase):
|
||||
select_template([])
|
||||
|
||||
def test_select_template_not_found(self):
|
||||
with self.assertRaises(TemplateDoesNotExist):
|
||||
with self.assertRaises(TemplateDoesNotExist) as e:
|
||||
select_template(["template_loader/unknown.html",
|
||||
"template_loader/missing.html"])
|
||||
self.assertEqual(
|
||||
e.exception.tried[0][0].template_name,
|
||||
'template_loader/unknown.html',
|
||||
)
|
||||
self.assertEqual(
|
||||
e.exception.tried[-1][0].template_name,
|
||||
'template_loader/missing.html',
|
||||
)
|
||||
|
||||
def test_select_template_tries_all_engines_before_names(self):
|
||||
template = select_template(["template_loader/goodbye.html",
|
||||
@@ -83,8 +95,12 @@ class TemplateLoaderTests(SimpleTestCase):
|
||||
self.assertEqual(content, "Hello! (Django templates)\n")
|
||||
|
||||
def test_render_to_string_not_found(self):
|
||||
with self.assertRaises(TemplateDoesNotExist):
|
||||
with self.assertRaises(TemplateDoesNotExist) as e:
|
||||
render_to_string("template_loader/unknown.html")
|
||||
self.assertEqual(
|
||||
e.exception.tried[-1][0].template_name,
|
||||
'template_loader/unknown.html',
|
||||
)
|
||||
|
||||
def test_render_to_string_with_list_first_engine(self):
|
||||
content = render_to_string(["template_loader/unknown.html",
|
||||
@@ -106,9 +122,17 @@ class TemplateLoaderTests(SimpleTestCase):
|
||||
render_to_string([])
|
||||
|
||||
def test_render_to_string_with_list_not_found(self):
|
||||
with self.assertRaises(TemplateDoesNotExist):
|
||||
with self.assertRaises(TemplateDoesNotExist) as e:
|
||||
render_to_string(["template_loader/unknown.html",
|
||||
"template_loader/missing.html"])
|
||||
self.assertEqual(
|
||||
e.exception.tried[0][0].template_name,
|
||||
'template_loader/unknown.html',
|
||||
)
|
||||
self.assertEqual(
|
||||
e.exception.tried[-1][0].template_name,
|
||||
'template_loader/missing.html',
|
||||
)
|
||||
|
||||
def test_render_to_string_with_list_tries_all_engines_before_names(self):
|
||||
content = render_to_string(["template_loader/goodbye.html",
|
||||
|
||||
Reference in New Issue
Block a user