Ticket #10853: 10853-1.diff

File 10853-1.diff, 1.4 KB (added by Claude Paroz, 13 years ago)

Set explicit cache for CacheSessionTests

  • django/contrib/sessions/tests.py

    diff --git a/django/contrib/sessions/tests.py b/django/contrib/sessions/tests.py
    index 776e03c..0b850f1 100644
    a b class CacheDBSessionTests(SessionTestsMixin, TestCase):  
    283283
    284284    backend = CacheDBSession
    285285
     286
    286287# Don't need DB flushing for these tests, so can use unittest.TestCase as base class
    287288class FileSessionTests(SessionTestsMixin, unittest.TestCase):
    288289
    class CacheSessionTests(SessionTestsMixin, unittest.TestCase):  
    320321
    321322    backend = CacheSession
    322323
     324CacheSessionTests = override_settings(
     325    # Some tests may fail if cache is dummy backend
     326    CACHES = {
     327        'default': {
     328            'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
     329        },
     330    },
     331)(CacheSessionTests)
     332
    323333
    324334class SessionMiddlewareTests(unittest.TestCase):
    325335
  • django/test/utils.py

    diff --git a/django/test/utils.py b/django/test/utils.py
    index 87f2311..e938a8b 100644
    a b class override_settings(object):  
    218218        override = OverrideSettingsHolder(settings._wrapped)
    219219        for key, new_value in self.options.items():
    220220            setattr(override, key, new_value)
     221        if 'CACHES' in self.options:
     222            from django.core import cache
     223            cache.cache = cache.get_cache(cache.DEFAULT_CACHE_ALIAS)
    221224        settings._wrapped = override
    222225
    223226    def disable(self):
Back to Top