From 19a5f6da329d58653bcda85f84efd5d5eaf68f84 Mon Sep 17 00:00:00 2001 From: Aaron Elliot Ross Date: Sun, 8 Nov 2015 10:06:07 +0100 Subject: Fixed #25469 -- Added autoescape option to DjangoTemplates backend. Thanks Aymeric for the initial patch and Carl for review. --- tests/template_backends/test_django.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests') 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' + ) -- cgit v1.3