diff options
author | Aaron Elliot Ross <aaronelliotross@gmail.com> | 2015-11-08 10:06:07 +0100 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2015-11-12 19:14:23 -0500 |
commit | 19a5f6da329d58653bcda85f84efd5d5eaf68f84 (patch) | |
tree | 52f6955cff728d3050710f70ba0a735e99704643 /tests/template_backends | |
parent | a8f05f405f8b78e13d7c4c9ffd73d6182b6fc4d5 (diff) | |
download | django-19a5f6da329d58653bcda85f84efd5d5eaf68f84.tar.gz |
Fixed #25469 -- Added autoescape option to DjangoTemplates backend.
Thanks Aymeric for the initial patch and Carl for review.
Diffstat (limited to 'tests/template_backends')
-rw-r--r-- | tests/template_backends/test_django.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/template_backends/test_django.py b/tests/template_backends/test_django.py index 8d13aaee08..1a93a82274 100644 --- a/tests/template_backends/test_django.py +++ b/tests/template_backends/test_django.py @@ -1,5 +1,6 @@ from template_tests.test_response import test_processor_name +from django.template import EngineHandler from django.template.backends.django import DjangoTemplates from django.template.library import InvalidTemplateLibrary from django.test import RequestFactory, override_settings @@ -108,3 +109,24 @@ class DjangoTemplatesTests(TemplateStringsTests): 'template_backends.apps.good.templatetags.good_tags', ] ) + + def test_autoescape_off(self): + templates = [{ + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'OPTIONS': {'autoescape': False}, + }] + engines = EngineHandler(templates=templates) + self.assertEqual( + engines['django'].from_string('Hello, {{ name }}').render({'name': 'Bob & Jim'}), + 'Hello, Bob & Jim' + ) + + def test_autoescape_default(self): + templates = [{ + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + }] + engines = EngineHandler(templates=templates) + self.assertEqual( + engines['django'].from_string('Hello, {{ name }}').render({'name': 'Bob & Jim'}), + 'Hello, Bob & Jim' + ) |