Ticket #16366: 16366-2.diff

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

Patch with override_settings

  • 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..e6dd353 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(MIDDLEWARE_CLASSES=global_settings.MIDDLEWARE_CLASSES)
    2518    def test_session_not_accessed(self):
    2619        """
    2720        Tests that the session is not accessed simply by including
    class AuthContextProcessorTests(TestCase):  
    3023        response = self.client.get('/auth_processor_no_attr_access/')
    3124        self.assertContains(response, "Session not accessed")
    3225
     26    @override_settings(MIDDLEWARE_CLASSES=global_settings.MIDDLEWARE_CLASSES)
    3327    def test_session_is_accessed(self):
    3428        """
    3529        Tests that the session is accessed if the auth context processor
    class AuthContextProcessorTests(TestCase):  
    8680        # See bug #12060
    8781        self.assertEqual(response.context['user'], user)
    8882        self.assertEqual(user, response.context['user'])
     83
     84AuthContextProcessorTests = override_settings(
     85    TEMPLATE_DIRS = (
     86            os.path.join(os.path.dirname(__file__), 'templates'),
     87        )
     88)(AuthContextProcessorTests)
Back to Top