Code

Ticket #16366: 16366-3.diff

File 16366-3.diff, 2.1 KB (added by claudep, 2 years ago)

Added TEMPLATE_CONTEXT_PROCESSORS to override

Line 
1diff --git a/django/contrib/auth/tests/context_processors.py b/django/contrib/auth/tests/context_processors.py
2index 49172c6..5b78ded 100644
3--- a/django/contrib/auth/tests/context_processors.py
4+++ b/django/contrib/auth/tests/context_processors.py
5@@ -1,9 +1,10 @@
6 import os
7 
8-from django.conf import settings
9+from django.conf import settings, global_settings
10 from django.contrib.auth import authenticate
11 from django.db.models import Q
12 from django.test import TestCase
13+from django.test.utils import override_settings
14 
15 
16 class AuthContextProcessorTests(TestCase):
17@@ -13,15 +14,10 @@ class AuthContextProcessorTests(TestCase):
18     urls = 'django.contrib.auth.tests.urls'
19     fixtures = ['context-processors-users.xml']
20 
21-    def setUp(self):
22-        self.old_TEMPLATE_DIRS = settings.TEMPLATE_DIRS
23-        settings.TEMPLATE_DIRS = (
24-            os.path.join(os.path.dirname(__file__), 'templates'),
25-        )
26-
27-    def tearDown(self):
28-        settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS
29-
30+    @override_settings(
31+        MIDDLEWARE_CLASSES=global_settings.MIDDLEWARE_CLASSES,
32+        TEMPLATE_CONTEXT_PROCESSORS=global_settings.TEMPLATE_CONTEXT_PROCESSORS,
33+    )
34     def test_session_not_accessed(self):
35         """
36         Tests that the session is not accessed simply by including
37@@ -30,6 +26,10 @@ class AuthContextProcessorTests(TestCase):
38         response = self.client.get('/auth_processor_no_attr_access/')
39         self.assertContains(response, "Session not accessed")
40 
41+    @override_settings(
42+        MIDDLEWARE_CLASSES=global_settings.MIDDLEWARE_CLASSES,
43+        TEMPLATE_CONTEXT_PROCESSORS=global_settings.TEMPLATE_CONTEXT_PROCESSORS,
44+    )
45     def test_session_is_accessed(self):
46         """
47         Tests that the session is accessed if the auth context processor
48@@ -86,3 +86,9 @@ class AuthContextProcessorTests(TestCase):
49         # See bug #12060
50         self.assertEqual(response.context['user'], user)
51         self.assertEqual(user, response.context['user'])
52+
53+AuthContextProcessorTests = override_settings(
54+    TEMPLATE_DIRS = (
55+            os.path.join(os.path.dirname(__file__), 'templates'),
56+        )
57+)(AuthContextProcessorTests)