diff options
| author | Preston Timmons <prestontimmons@gmail.com> | 2015-03-03 15:48:26 -0600 |
|---|---|---|
| committer | Preston Timmons <prestontimmons@gmail.com> | 2015-04-22 14:49:00 -0500 |
| commit | fc2147152637e21bc73f991b50fa06254af02739 (patch) | |
| tree | c9f80c73aabf680e67c6646361d8de3a29a62f93 /tests/template_loader/tests.py | |
| parent | 1b1b58bc7b2917b203ee3eb3b9e8b3a1fafaee64 (diff) | |
Fixed #15053 -- Enabled recursive template loading.
Diffstat (limited to 'tests/template_loader/tests.py')
| -rw-r--r-- | tests/template_loader/tests.py | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/tests/template_loader/tests.py b/tests/template_loader/tests.py index a4a4542f32..c698c0a398 100644 --- a/tests/template_loader/tests.py +++ b/tests/template_loader/tests.py @@ -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", |
