| 1 | from django.test import TestCase, override_settings, RequestFactory
|
|---|
| 2 | from django.template import RequestContext
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 | def test_processor(request):
|
|---|
| 6 | return {'processors': 'yes'}
|
|---|
| 7 | test_processor_name = 'template_tests.test_response.test_processor'
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 | @override_settings(
|
|---|
| 11 | TEMPLATE_CONTEXT_PROCESSORS=[test_processor_name],
|
|---|
| 12 | TEMPLATES=[{
|
|---|
| 13 | 'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|---|
| 14 | 'OPTIONS': {
|
|---|
| 15 | 'context_processors': [test_processor_name],
|
|---|
| 16 | },
|
|---|
| 17 | }])
|
|---|
| 18 | class Test(TestCase):
|
|---|
| 19 | def test_context_processor(self):
|
|---|
| 20 | request = RequestFactory().get('/')
|
|---|
| 21 | context = RequestContext(request)
|
|---|
| 22 | self.assertEqual(context['processors'], 'yes')
|
|---|