diff options
Diffstat (limited to 'tests/template_loader')
| -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", |
