summaryrefslogtreecommitdiff
path: root/tests/context_processors
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2014-12-14 10:17:18 +0100
committerAymeric Augustin <aymeric.augustin@m4x.org>2014-12-28 17:02:29 +0100
commitfdbfc98003f0ba2d3a12def63a75560791f3602d (patch)
tree0238fba169970595f1a8c44d53550fada6236b4f /tests/context_processors
parenta0141f9eac03f0fef722e757253bbc939c018f77 (diff)
downloaddjango-fdbfc98003f0ba2d3a12def63a75560791f3602d.tar.gz
Deprecated some arguments of django.shortcuts.render(_to_response).
dictionary and context_instance and superseded by context. Refactored tests that relied context_instance with more modern idioms.
Diffstat (limited to 'tests/context_processors')
-rw-r--r--tests/context_processors/tests.py12
-rw-r--r--tests/context_processors/views.py16
2 files changed, 14 insertions, 14 deletions
diff --git a/tests/context_processors/tests.py b/tests/context_processors/tests.py
index 8d58f5c695..7a0d8220a8 100644
--- a/tests/context_processors/tests.py
+++ b/tests/context_processors/tests.py
@@ -4,7 +4,10 @@ Tests for Django's bundled context processors.
from django.test import TestCase, override_settings
-@override_settings(ROOT_URLCONF='context_processors.urls')
+@override_settings(
+ ROOT_URLCONF='context_processors.urls',
+ TEMPLATE_CONTEXT_PROCESSORS=('django.template.context_processors.request',),
+)
class RequestContextProcessorTests(TestCase):
"""
Tests for the ``django.template.context_processors.request`` processor.
@@ -35,7 +38,12 @@ class RequestContextProcessorTests(TestCase):
self.assertContains(response, url)
-@override_settings(ROOT_URLCONF='context_processors.urls', DEBUG=True, INTERNAL_IPS=('127.0.0.1',))
+@override_settings(
+ DEBUG=True,
+ INTERNAL_IPS=('127.0.0.1',),
+ ROOT_URLCONF='context_processors.urls',
+ TEMPLATE_CONTEXT_PROCESSORS=('django.template.context_processors.debug',),
+)
class DebugContextProcessorTests(TestCase):
"""
Tests for the ``django.template.context_processors.debug`` processor.
diff --git a/tests/context_processors/views.py b/tests/context_processors/views.py
index 913877f20a..1a7eda0b16 100644
--- a/tests/context_processors/views.py
+++ b/tests/context_processors/views.py
@@ -1,20 +1,12 @@
-from django.shortcuts import render_to_response
-from django.template import context_processors
-from django.template.context import RequestContext
+from django.shortcuts import render
from .models import DebugObject
def request_processor(request):
- return render_to_response(
- 'context_processors/request_attrs.html',
- context_instance=RequestContext(request, {}, processors=[context_processors.request]))
+ return render(request, 'context_processors/request_attrs.html')
def debug_processor(request):
-
- return render_to_response(
- 'context_processors/debug.html',
- context_instance=RequestContext(request, {
- 'debug_objects': DebugObject.objects,
- }, processors=[context_processors.debug]))
+ context = {'debug_objects': DebugObject.objects}
+ return render(request, 'context_processors/debug.html', context)