Ticket #17848: 17848-3.diff

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

Update patch for current trunk

  • 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 bba2046..31a56f4 100644
    a b class AuthContextProcessorTests(TestCase):  
    3030        Tests that the session is not accessed simply by including
    3131        the auth context processor
    3232        """
    33         context._standard_context_processors = None
    34 
    3533        response = self.client.get('/auth_processor_no_attr_access/')
    3634        self.assertContains(response, "Session not accessed")
    3735
    38         context._standard_context_processors = None
    39 
    4036    @override_settings(
    4137        MIDDLEWARE_CLASSES=global_settings.MIDDLEWARE_CLASSES,
    4238        TEMPLATE_CONTEXT_PROCESSORS=global_settings.TEMPLATE_CONTEXT_PROCESSORS,
    class AuthContextProcessorTests(TestCase):  
    4642        Tests that the session is accessed if the auth context processor
    4743        is used and relevant attributes accessed.
    4844        """
    49         context._standard_context_processors = None
    50 
    5145        response = self.client.get('/auth_processor_attr_access/')
    5246        self.assertContains(response, "Session accessed")
    5347
    54         context._standard_context_processors = None
    55 
    5648    def test_perms_attrs(self):
    5749        self.client.login(username='super', password='secret')
    5850        response = self.client.get('/auth_processor_perms/')
  • django/contrib/messages/tests/base.py

    diff --git a/django/contrib/messages/tests/base.py b/django/contrib/messages/tests/base.py
    index 8d04532..4a00324 100644
    a b class BaseTest(TestCase):  
    259259                              args=(level,))
    260260            response = self.client.post(add_url, data, follow=True)
    261261            self.assertRedirects(response, show_url)
    262             self.assertTrue('messages' in response.context)
    263             self.assertEqual(list(response.context['messages']), [])
     262            self.assertFalse('messages' in response.context)
    264263
    265264    def stored_messages_count(self, storage, response):
    266265        """
  • django/test/signals.py

    diff --git a/django/test/signals.py b/django/test/signals.py
    index 01d5581..ed16831 100644
    a b  
    11from django.conf import settings
    22from django.db import connections
    3 from django.dispatch import Signal
     3from django.dispatch import receiver, Signal
     4from django.template import context
    45
    56template_rendered = Signal(providing_args=["template", "context"])
    67
    78setting_changed = Signal(providing_args=["setting", "value"])
    89
     10@receiver(setting_changed)
    911def update_connections_time_zone(**kwargs):
    1012    if kwargs['setting'] == 'USE_TZ' and settings.TIME_ZONE != 'UTC':
    1113        USE_TZ, TIME_ZONE = kwargs['value'], settings.TIME_ZONE
    def update_connections_time_zone(**kwargs):  
    2022        if tz_sql:
    2123            conn.cursor().execute(tz_sql, [tz])
    2224
    23 setting_changed.connect(update_connections_time_zone)
     25@receiver(setting_changed)
     26def clear_context_processors_cache(**kwargs):
     27    if kwargs['setting'] == 'TEMPLATE_CONTEXT_PROCESSORS':
     28        context._standard_context_processors = None
  • tests/regressiontests/admin_views/tests.py

    diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py
    index 564e492..d2d6c87 100644
    a b import re  
    66import datetime
    77import urlparse
    88
    9 from django.conf import settings
     9from django.conf import settings, global_settings
    1010from django.core import mail
    1111from django.core.exceptions import SuspiciousOperation
    1212from django.core.files import temp as tempfile
    from django.contrib.auth import REDIRECT_FIELD_NAME  
    2323from django.contrib.auth.models import Group, User, Permission, UNUSABLE_PASSWORD
    2424from django.contrib.contenttypes.models import ContentType
    2525from django.forms.util import ErrorList
    26 from django.template import context as context_module
    2726from django.template.response import TemplateResponse
    2827from django.test import TestCase
    2928from django.utils import formats, translation, unittest
    class ValidXHTMLTests(TestCase):  
    33643363    urlbit = 'admin'
    33653364
    33663365    def setUp(self):
    3367         self._context_processors = None
    3368         self._use_i18n, settings.USE_I18N = settings.USE_I18N, False
    3369         if 'django.core.context_processors.i18n' in settings.TEMPLATE_CONTEXT_PROCESSORS:
    3370             self._context_processors = settings.TEMPLATE_CONTEXT_PROCESSORS
    3371             cp = list(settings.TEMPLATE_CONTEXT_PROCESSORS)
    3372             cp.remove('django.core.context_processors.i18n')
    3373             settings.TEMPLATE_CONTEXT_PROCESSORS = tuple(cp)
    3374             # Force re-evaluation of the contex processor list
    3375             context_module._standard_context_processors = None
    33763366        self.client.login(username='super', password='secret')
    33773367
    33783368    def tearDown(self):
    33793369        self.client.logout()
    3380         if self._context_processors is not None:
    3381             settings.TEMPLATE_CONTEXT_PROCESSORS = self._context_processors
    3382             # Force re-evaluation of the contex processor list
    3383             context_module._standard_context_processors = None
    3384         settings.USE_I18N = self._use_i18n
    33853370
     3371    @override_settings(
     3372        TEMPLATE_CONTEXT_PROCESSORS=filter(
     3373            lambda t:t!='django.core.context_processors.i18n',
     3374            global_settings.TEMPLATE_CONTEXT_PROCESSORS),
     3375        USE_I18N=False,
     3376    )
    33863377    def testLangNamePresent(self):
    33873378        response = self.client.get('/test_admin/%s/admin_views/' % self.urlbit)
    33883379        self.assertFalse(' lang=""' in response.content)
  • tests/regressiontests/templates/response.py

    diff --git a/tests/regressiontests/templates/response.py b/tests/regressiontests/templates/response.py
    index 7c59da2..3c45b7a 100644
    a b import pickle  
    33import time
    44from datetime import datetime
    55
    6 from django.utils import unittest
    76from django.test import RequestFactory, TestCase
    87from django.conf import settings
    9 import django.template.context
    108from django.template import Template, Context
    119from django.template.response import (TemplateResponse, SimpleTemplateResponse,
    1210                                      ContentNotRenderedError)
     11from django.test.utils import override_settings
    1312
    1413def test_processor(request):
    1514    return {'processors': 'yes'}
    class CustomURLConfMiddleware(object):  
    2221        request.urlconf = 'regressiontests.templates.alternate_urls'
    2322
    2423
    25 class BaseTemplateResponseTest(unittest.TestCase):
    26     # tests rely on fact that global context
    27     # processors should only work when RequestContext is used.
    28 
    29     def setUp(self):
    30         self.factory = RequestFactory()
    31         self._old_processors = settings.TEMPLATE_CONTEXT_PROCESSORS
    32         self._old_TEMPLATE_DIRS = settings.TEMPLATE_DIRS
    33         settings.TEMPLATE_CONTEXT_PROCESSORS = [test_processor_name]
    34         settings.TEMPLATE_DIRS = (
    35             os.path.join(
    36                 os.path.dirname(__file__),
    37                 'templates'
    38             ),
    39         )
    40         # Force re-evaluation of the contex processor list
    41         django.template.context._standard_context_processors = None
    42 
    43     def tearDown(self):
    44         settings.TEMPLATE_DIRS = self._old_TEMPLATE_DIRS
    45         settings.TEMPLATE_CONTEXT_PROCESSORS = self._old_processors
    46         # Force re-evaluation of the contex processor list
    47         django.template.context._standard_context_processors = None
    48 
    49 
    50 class SimpleTemplateResponseTest(BaseTemplateResponseTest):
     24class SimpleTemplateResponseTest(TestCase):
    5125
    5226    def _response(self, template='foo', *args, **kwargs):
    5327        return SimpleTemplateResponse(Template(template), *args, **kwargs)
    class SimpleTemplateResponseTest(BaseTemplateResponseTest):  
    213187        unpickled_response = pickle.loads(pickled_response)
    214188        repickled_response = pickle.dumps(unpickled_response)
    215189
    216 class TemplateResponseTest(BaseTemplateResponseTest):
     190@override_settings(
     191    TEMPLATE_CONTEXT_PROCESSORS=[test_processor_name],
     192    TEMPLATE_DIRS=(os.path.join(os.path.dirname(__file__),'templates')),
     193)
     194class TemplateResponseTest(TestCase):
     195
     196    def setUp(self):
     197        self.factory = RequestFactory()
    217198
    218199    def _response(self, template='foo', *args, **kwargs):
    219200        return TemplateResponse(self.factory.get('/'), Template(template),
  • tests/regressiontests/templates/tests.py

    diff --git a/tests/regressiontests/templates/tests.py b/tests/regressiontests/templates/tests.py
    index e166f7e..e40ffcb 100644
    a b from .parser import ParserTests  
    3737from .unicode import UnicodeTests
    3838from .nodelist import NodelistTest, ErrorIndexTest
    3939from .smartif import SmartIfTests
    40 from .response import (TemplateResponseTest, BaseTemplateResponseTest,
    41     CacheMiddlewareTest, SimpleTemplateResponseTest, CustomURLConfTest)
     40from .response import (TemplateResponseTest, CacheMiddlewareTest,
     41    SimpleTemplateResponseTest, CustomURLConfTest)
    4242
    4343try:
    4444    from .loaders import RenderToStringTest, EggLoaderTest
    class TemplateTagLoading(unittest.TestCase):  
    17381738        t = template.Template(ttext)
    17391739
    17401740
    1741 class RequestContextTests(BaseTemplateResponseTest):
     1741class RequestContextTests(unittest.TestCase):
    17421742
    17431743    def setUp(self):
    17441744        templates = {
  • tests/regressiontests/views/tests/shortcuts.py

    diff --git a/tests/regressiontests/views/tests/shortcuts.py b/tests/regressiontests/views/tests/shortcuts.py
    index 24bf6bb..d20b6d1 100644
    a b import warnings  
    22
    33from django.conf import settings
    44from django.test import TestCase
     5from django.test.utils import override_settings
    56
     7@override_settings(
     8    TEMPLATE_CONTEXT_PROCESSORS=('django.core.context_processors.static',),
     9    STATIC_URL='/path/to/static/media/',
     10)
    611class ShortcutTests(TestCase):
    712    urls = 'regressiontests.views.generic_urls'
    813
    class ShortcutTests(TestCase):  
    1116        warnings.filterwarnings('ignore', category=DeprecationWarning,
    1217                                module='django.views.generic.simple')
    1318
    14         self.old_STATIC_URL = settings.STATIC_URL
    15         self.old_TEMPLATE_CONTEXT_PROCESSORS = settings.TEMPLATE_CONTEXT_PROCESSORS
    16 
    17         settings.STATIC_URL = '/path/to/static/media/'
    18         settings.TEMPLATE_CONTEXT_PROCESSORS = (
    19             'django.core.context_processors.static'
    20         )
    21 
    2219    def tearDown(self):
    2320        self.restore_warnings_state()
    2421
    25     def tearDown(self):
    26         settings.STATIC_URL = self.old_STATIC_URL
    27         settings.TEMPLATE_CONTEXT_PROCESSORS = self.old_TEMPLATE_CONTEXT_PROCESSORS
    28 
    2922    def test_render_to_response(self):
    3023        response = self.client.get('/shortcuts/render_to_response/')
    3124        self.assertEqual(response.status_code, 200)
    class ShortcutTests(TestCase):  
    7467
    7568    def test_render_with_current_app_conflict(self):
    7669        self.assertRaises(ValueError, self.client.get, '/shortcuts/render/current_app_conflict/')
    77 
Back to Top