diff options
author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2015-01-03 19:28:15 +0100 |
---|---|---|
committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2015-01-07 21:54:22 +0100 |
commit | 127f9e073d83904defd4bde4eaa4491f3306ca25 (patch) | |
tree | 29517d65351d6390d386f4579ee86f53ad0985ce /tests/shortcuts | |
parent | eaa1a22341aef5b92f5c3cd682f01e61c4159262 (diff) | |
download | django-127f9e073d83904defd4bde4eaa4491f3306ca25.tar.gz |
Restored support for multiple template names in render(_to_response).
This possibility was documented but not tested.
It had been broken during the multiple template engines refactor.
Diffstat (limited to 'tests/shortcuts')
-rw-r--r-- | tests/shortcuts/tests.py | 10 | ||||
-rw-r--r-- | tests/shortcuts/urls.py | 2 | ||||
-rw-r--r-- | tests/shortcuts/views.py | 20 |
3 files changed, 32 insertions, 0 deletions
diff --git a/tests/shortcuts/tests.py b/tests/shortcuts/tests.py index 612f4a3dd8..f5351dfa03 100644 --- a/tests/shortcuts/tests.py +++ b/tests/shortcuts/tests.py @@ -14,6 +14,11 @@ class ShortcutTests(TestCase): self.assertEqual(response.content, b'FOO.BAR..\n') self.assertEqual(response['Content-Type'], 'text/html; charset=utf-8') + def test_render_to_response_with_multiple_templates(self): + response = self.client.get('/render_to_response/multiple_templates/') + self.assertEqual(response.status_code, 200) + self.assertEqual(response.content, b'FOO.BAR..\n') + @ignore_warnings(category=RemovedInDjango20Warning) def test_render_to_response_with_request_context(self): response = self.client.get('/render_to_response/request_context/') @@ -51,6 +56,11 @@ class ShortcutTests(TestCase): self.assertEqual(response['Content-Type'], 'text/html; charset=utf-8') self.assertFalse(hasattr(response.context.request, 'current_app')) + def test_render_with_multiple_templates(self): + response = self.client.get('/render/multiple_templates/') + self.assertEqual(response.status_code, 200) + self.assertEqual(response.content, b'FOO.BAR../path/to/static/media/\n') + @ignore_warnings(category=RemovedInDjango20Warning) def test_render_with_base_context(self): response = self.client.get('/render/base_context/') diff --git a/tests/shortcuts/urls.py b/tests/shortcuts/urls.py index f02e74a745..cbb6c99c14 100644 --- a/tests/shortcuts/urls.py +++ b/tests/shortcuts/urls.py @@ -4,11 +4,13 @@ from . import views urlpatterns = [ url(r'^render_to_response/$', views.render_to_response_view), + url(r'^render_to_response/multiple_templates/$', views.render_to_response_view_with_multiple_templates), url(r'^render_to_response/request_context/$', views.render_to_response_view_with_request_context), url(r'^render_to_response/content_type/$', views.render_to_response_view_with_content_type), url(r'^render_to_response/dirs/$', views.render_to_response_view_with_dirs), url(r'^render_to_response/context_instance_misuse/$', views.render_to_response_with_context_instance_misuse), url(r'^render/$', views.render_view), + url(r'^render/multiple_templates/$', views.render_view_with_multiple_templates), url(r'^render/base_context/$', views.render_view_with_base_context), url(r'^render/content_type/$', views.render_view_with_content_type), url(r'^render/dirs/$', views.render_with_dirs), diff --git a/tests/shortcuts/views.py b/tests/shortcuts/views.py index 66196f11cf..42493f3e7b 100644 --- a/tests/shortcuts/views.py +++ b/tests/shortcuts/views.py @@ -15,6 +15,16 @@ def render_to_response_view(request): }) +def render_to_response_view_with_multiple_templates(request): + return render_to_response([ + 'shortcuts/no_such_template.html', + 'shortcuts/render_test.html', + ], { + 'foo': 'FOO', + 'bar': 'BAR', + }) + + def render_to_response_view_with_request_context(request): return render_to_response('shortcuts/render_test.html', { 'foo': 'FOO', @@ -50,6 +60,16 @@ def render_view(request): }) +def render_view_with_multiple_templates(request): + return render(request, [ + 'shortcuts/no_such_template.html', + 'shortcuts/render_test.html', + ], { + 'foo': 'FOO', + 'bar': 'BAR', + }) + + def render_view_with_base_context(request): return render(request, 'shortcuts/render_test.html', { 'foo': 'FOO', |