Ticket #16366: 16366-3.diff

File 16366-3.diff, 2.1 KB (added by Claude Paroz, 13 years ago)

Added TEMPLATE_CONTEXT_PROCESSORS to override

  • django/contrib/auth/tests/context_processors.py

    diff --git a/django/contrib/auth/tests/context_processors.py b/django/contrib/auth/tests/context_processors.py
    index 49172c6..5b78ded 100644
    a b  
    11import os
    22
    3 from django.conf import settings
     3from django.conf import settings, global_settings
    44from django.contrib.auth import authenticate
    55from django.db.models import Q
    66from django.test import TestCase
     7from django.test.utils import override_settings
    78
    89
    910class AuthContextProcessorTests(TestCase):
    class AuthContextProcessorTests(TestCase):  
    1314    urls = 'django.contrib.auth.tests.urls'
    1415    fixtures = ['context-processors-users.xml']
    1516
    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 
     17    @override_settings(
     18        MIDDLEWARE_CLASSES=global_settings.MIDDLEWARE_CLASSES,
     19        TEMPLATE_CONTEXT_PROCESSORS=global_settings.TEMPLATE_CONTEXT_PROCESSORS,
     20    )
    2521    def test_session_not_accessed(self):
    2622        """
    2723        Tests that the session is not accessed simply by including
    class AuthContextProcessorTests(TestCase):  
    3026        response = self.client.get('/auth_processor_no_attr_access/')
    3127        self.assertContains(response, "Session not accessed")
    3228
     29    @override_settings(
     30        MIDDLEWARE_CLASSES=global_settings.MIDDLEWARE_CLASSES,
     31        TEMPLATE_CONTEXT_PROCESSORS=global_settings.TEMPLATE_CONTEXT_PROCESSORS,
     32    )
    3333    def test_session_is_accessed(self):
    3434        """
    3535        Tests that the session is accessed if the auth context processor
    class AuthContextProcessorTests(TestCase):  
    8686        # See bug #12060
    8787        self.assertEqual(response.context['user'], user)
    8888        self.assertEqual(user, response.context['user'])
     89
     90AuthContextProcessorTests = override_settings(
     91    TEMPLATE_DIRS = (
     92            os.path.join(os.path.dirname(__file__), 'templates'),
     93        )
     94)(AuthContextProcessorTests)
Back to Top