mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #17529 -- get_template_from_string default arguments break
``get_template_from_string`` default arguments were breaking ``assertTemplateUsed``. The solution has been to return only the names of the templates with a ``name`` attribute distinct of ``None``. The default ``name`` kwarg of ``Template`` has been changed to ``None``, more pythonic than ``'<Unknown Template>'``.
This commit is contained in:
committed by
Claude Paroz
parent
bc21e9c0d9
commit
72f63bd24d
@@ -214,6 +214,8 @@ class AssertNumQueriesContextManagerTests(TestCase):
|
||||
|
||||
|
||||
class AssertTemplateUsedContextManagerTests(TestCase):
|
||||
urls = 'test_utils.urls'
|
||||
|
||||
def test_usage(self):
|
||||
with self.assertTemplateUsed('template_used/base.html'):
|
||||
render_to_string('template_used/base.html')
|
||||
@@ -270,6 +272,11 @@ class AssertTemplateUsedContextManagerTests(TestCase):
|
||||
with self.assertTemplateUsed('template_used/base.html'):
|
||||
render_to_string('template_used/alternative.html')
|
||||
|
||||
with self.assertRaises(AssertionError) as cm:
|
||||
response = self.client.get('/test_utils/no_template_used/')
|
||||
self.assertTemplateUsed(response, 'template_used/base.html')
|
||||
self.assertEqual(cm.exception.args[0], "No templates used to render the response")
|
||||
|
||||
def test_failure(self):
|
||||
with self.assertRaises(TypeError):
|
||||
with self.assertTemplateUsed():
|
||||
|
||||
Reference in New Issue
Block a user