diff options
| author | Unai Zalakain <unai@gisa-elkartea.org> | 2013-11-04 16:50:14 +0100 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2013-11-08 17:10:37 +0100 |
| commit | 72f63bd24d44b5a4f24ad8fa27ebba96d9a507d8 (patch) | |
| tree | 03ad4a7dd8a6be5975da0478c67ba0a6409ba482 /tests/test_utils/tests.py | |
| parent | bc21e9c0d9253f9d49a0063830a645d1c724c696 (diff) | |
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>'``.
Diffstat (limited to 'tests/test_utils/tests.py')
| -rw-r--r-- | tests/test_utils/tests.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/test_utils/tests.py b/tests/test_utils/tests.py index 666fde2fa6..9f7831d2b7 100644 --- a/tests/test_utils/tests.py +++ b/tests/test_utils/tests.py @@ -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(): |
