mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #24694 -- Added support for context_processors to Jinja2 backend.
This commit is contained in:
committed by
Tim Graham
parent
222e1334bf
commit
52a991d976
@@ -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/')
|
||||
|
||||
Reference in New Issue
Block a user