Fixed #15053 -- Enabled recursive template loading.

This commit is contained in:
Preston Timmons 2015-03-03 15:48:26 -06:00
parent 1b1b58bc7b
commit fc21471526
25 changed files with 740 additions and 129 deletions

View file

@ -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",