summaryrefslogtreecommitdiff
path: root/tests/template_backends
diff options
context:
space:
mode:
authorBerker Peksag <berker.peksag@gmail.com>2016-06-27 16:56:21 +0300
committerTim Graham <timograham@gmail.com>2016-06-28 14:30:54 -0400
commit52a991d9766de08b411ee05e2166ed9576da3458 (patch)
tree71434dfc527725b5784b04b198cc79a5e12f31af /tests/template_backends
parent222e1334bf29605925eefa45ff107ca1155e93c0 (diff)
downloaddjango-52a991d9766de08b411ee05e2166ed9576da3458.tar.gz
Fixed #24694 -- Added support for context_processors to Jinja2 backend.
Diffstat (limited to 'tests/template_backends')
-rw-r--r--tests/template_backends/test_jinja2.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/tests/template_backends/test_jinja2.py b/tests/template_backends/test_jinja2.py
index 831a84c8c0..a79c6bc460 100644
--- a/tests/template_backends/test_jinja2.py
+++ b/tests/template_backends/test_jinja2.py
@@ -5,6 +5,7 @@ from __future__ import absolute_import
from unittest import skipIf
from django.template import TemplateSyntaxError
+from django.test import RequestFactory
from .test_dummy import TemplateStringsTests
@@ -22,7 +23,12 @@ class Jinja2Tests(TemplateStringsTests):
engine_class = Jinja2
backend_name = 'jinja2'
- options = {'keep_trailing_newline': True}
+ options = {
+ 'keep_trailing_newline': True,
+ 'context_processors': [
+ 'django.template.context_processors.static',
+ ],
+ }
def test_origin(self):
template = self.engine.get_template('template_backends/hello.html')
@@ -74,3 +80,12 @@ class Jinja2Tests(TemplateStringsTests):
self.assertEqual(len(debug['source_lines']), 21)
self.assertTrue(debug['name'].endswith('syntax_error2.html'))
self.assertIn('message', debug)
+
+ def test_context_processors(self):
+ request = RequestFactory().get('/')
+ template = self.engine.from_string('Static URL: {{ STATIC_URL }}')
+ content = template.render(request=request)
+ self.assertEqual(content, 'Static URL: /static/')
+ with self.settings(STATIC_URL='/s/'):
+ content = template.render(request=request)
+ self.assertEqual(content, 'Static URL: /s/')