diff --git a/django/contrib/auth/tests/context_processors.py b/django/contrib/auth/tests/context_processors.py
index 49172c6..8f77940 100644
a
|
b
|
|
1 | 1 | import os |
2 | 2 | |
3 | | from django.conf import settings |
| 3 | from django.conf import global_settings |
4 | 4 | from django.contrib.auth import authenticate |
5 | 5 | from django.db.models import Q |
| 6 | from django.template import context |
6 | 7 | from django.test import TestCase |
| 8 | from django.test.utils import override_settings |
7 | 9 | |
8 | 10 | |
9 | 11 | class AuthContextProcessorTests(TestCase): |
… |
… |
class AuthContextProcessorTests(TestCase):
|
13 | 15 | urls = 'django.contrib.auth.tests.urls' |
14 | 16 | fixtures = ['context-processors-users.xml'] |
15 | 17 | |
16 | | def setUp(self): |
17 | | self.old_TEMPLATE_DIRS = settings.TEMPLATE_DIRS |
18 | | settings.TEMPLATE_DIRS = ( |
19 | | os.path.join(os.path.dirname(__file__), 'templates'), |
20 | | ) |
21 | | |
22 | | def tearDown(self): |
23 | | settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS |
24 | | |
| 18 | @override_settings( |
| 19 | MIDDLEWARE_CLASSES=global_settings.MIDDLEWARE_CLASSES, |
| 20 | TEMPLATE_CONTEXT_PROCESSORS=global_settings.TEMPLATE_CONTEXT_PROCESSORS, |
| 21 | ) |
25 | 22 | def test_session_not_accessed(self): |
26 | 23 | """ |
27 | 24 | Tests that the session is not accessed simply by including |
28 | 25 | the auth context processor |
29 | 26 | """ |
| 27 | context._standard_context_processors = None |
| 28 | |
30 | 29 | response = self.client.get('/auth_processor_no_attr_access/') |
31 | 30 | self.assertContains(response, "Session not accessed") |
32 | 31 | |
| 32 | @override_settings( |
| 33 | MIDDLEWARE_CLASSES=global_settings.MIDDLEWARE_CLASSES, |
| 34 | TEMPLATE_CONTEXT_PROCESSORS=global_settings.TEMPLATE_CONTEXT_PROCESSORS, |
| 35 | ) |
33 | 36 | def test_session_is_accessed(self): |
34 | 37 | """ |
35 | 38 | Tests that the session is accessed if the auth context processor |
36 | 39 | is used and relevant attributes accessed. |
37 | 40 | """ |
| 41 | context._standard_context_processors = None |
| 42 | |
38 | 43 | response = self.client.get('/auth_processor_attr_access/') |
39 | 44 | self.assertContains(response, "Session accessed") |
40 | 45 | |
… |
… |
class AuthContextProcessorTests(TestCase):
|
86 | 91 | # See bug #12060 |
87 | 92 | self.assertEqual(response.context['user'], user) |
88 | 93 | self.assertEqual(user, response.context['user']) |
| 94 | |
| 95 | AuthContextProcessorTests = override_settings( |
| 96 | TEMPLATE_DIRS = ( |
| 97 | os.path.join(os.path.dirname(__file__), 'templates'), |
| 98 | ) |
| 99 | )(AuthContextProcessorTests) |