diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/template_backends/test_django.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/template_backends/test_django.py b/tests/template_backends/test_django.py index 5c5070cb18..f332abbf24 100644 --- a/tests/template_backends/test_django.py +++ b/tests/template_backends/test_django.py @@ -1,4 +1,7 @@ from django.template.backends.django import DjangoTemplates +from django.test import RequestFactory + +from template_tests.test_response import test_processor_name from .test_dummy import TemplateStringsTests @@ -7,3 +10,25 @@ class DjangoTemplatesTests(TemplateStringsTests): engine_class = DjangoTemplates backend_name = 'django' + + def test_context_has_priority_over_template_context_processors(self): + # See ticket #23789. + engine = DjangoTemplates({ + 'DIRS': [], + 'APP_DIRS': False, + 'NAME': 'django', + 'OPTIONS': { + 'context_processors': [test_processor_name], + }, + }) + + template = engine.from_string('{{ processors }}') + request = RequestFactory().get('/') + + # Check that context processors run + content = template.render({}, request) + self.assertEqual(content, 'yes') + + # Check that context overrides context processors + content = template.render({'processors': 'no'}, request) + self.assertEqual(content, 'no') |
