diff options
author | Shivang Bharadwaj <reficul31@gmail.com> | 2016-12-29 02:33:20 +0530 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2016-12-28 16:03:20 -0500 |
commit | 6a7495051304d75865add6ff96422018984e1663 (patch) | |
tree | b0e74ccd6fea585afb7d15f2735dc3a80d10004d /tests/template_backends | |
parent | 4e89082f31689d05a1b3aeaabd325f1b2cdcda5b (diff) | |
download | django-6a7495051304d75865add6ff96422018984e1663.tar.gz |
Fixed #27258 -- Prohibited django.Template.render() with non-dict context.
Thanks Shivang Bharadwaj for the initial patch.
Diffstat (limited to 'tests/template_backends')
-rw-r--r-- | tests/template_backends/test_django.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/tests/template_backends/test_django.py b/tests/template_backends/test_django.py index 41eaff0c6d..567537f7a2 100644 --- a/tests/template_backends/test_django.py +++ b/tests/template_backends/test_django.py @@ -1,6 +1,6 @@ from template_tests.test_response import test_processor_name -from django.template import EngineHandler +from django.template import Context, EngineHandler, RequestContext from django.template.backends.django import DjangoTemplates from django.template.library import InvalidTemplateLibrary from django.test import RequestFactory, override_settings @@ -35,6 +35,24 @@ class DjangoTemplatesTests(TemplateStringsTests): content = template.render({'processors': 'no'}, request) self.assertEqual(content, 'no') + def test_render_requires_dict(self): + """django.Template.render() requires a dict.""" + engine = DjangoTemplates({ + 'DIRS': [], + 'APP_DIRS': False, + 'NAME': 'django', + 'OPTIONS': {}, + }) + template = engine.from_string('') + context = Context() + request_context = RequestContext(RequestFactory().get('/'), {}) + msg = 'context must be a dict rather than Context.' + with self.assertRaisesMessage(TypeError, msg): + template.render(context) + msg = 'context must be a dict rather than RequestContext.' + with self.assertRaisesMessage(TypeError, msg): + template.render(request_context) + @override_settings(INSTALLED_APPS=['template_backends.apps.good']) def test_templatetag_discovery(self): engine = DjangoTemplates({ |