Fixed #26109 -- Raised a helpful error if loader.select_tamplate() is passed a string.

This commit is contained in:
Ahmed Mohamed 2016-01-21 17:40:33 +09:00 committed by Tim Graham
parent 275d11fbc5
commit 229488c8a1
2 changed files with 16 additions and 0 deletions

View file

@ -60,6 +60,15 @@ class TemplateLoaderTests(SimpleTestCase):
with self.assertRaises(TemplateDoesNotExist):
select_template([])
def test_select_template_string(self):
with self.assertRaisesMessage(
TypeError,
"select_template() takes an iterable of template names but got a "
"string: 'template_loader/hello.html'. Use get_template() if you "
"want to load a single template by name."
):
select_template('template_loader/hello.html')
def test_select_template_not_found(self):
with self.assertRaises(TemplateDoesNotExist) as e:
select_template(["template_loader/unknown.html",