diff options
| author | Florian Apolloner <florian@apolloner.eu> | 2013-11-24 16:19:47 +0100 |
|---|---|---|
| committer | Florian Apolloner <florian@apolloner.eu> | 2013-11-24 16:23:28 +0100 |
| commit | d47f794f8fa05591632b8cad4b134858e7ae140d (patch) | |
| tree | e0191a2dfd1252c72a7bfa2191ae31f591027dfa /tests/cache | |
| parent | 8adbfdfcc4c6941ecdc5ba696dab03121568ba89 (diff) | |
Properly closed cache connections at the end of the request.
This only affects the new cache api and not the deprecated get_cache.
Refs #21012
Diffstat (limited to 'tests/cache')
| -rw-r--r-- | tests/cache/tests.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/tests/cache/tests.py b/tests/cache/tests.py index c4a941dbf8..5ca9a7d4db 100644 --- a/tests/cache/tests.py +++ b/tests/cache/tests.py @@ -203,7 +203,6 @@ _caches_setting_base = { 'custom_key2': {'KEY_FUNCTION': 'cache.tests.custom_key_func'}, 'cull': {'OPTIONS': {'MAX_ENTRIES': 30}}, 'zero_cull': {'OPTIONS': {'CULL_FREQUENCY': 0, 'MAX_ENTRIES': 30}}, - 'other': {'LOCATION': 'other'}, } @@ -1014,6 +1013,13 @@ class LocMemCacheTests(BaseCacheTests, TestCase): caches['custom_key2']._cache = cache._cache caches['custom_key2']._expire_info = cache._expire_info + @override_settings(CACHES={ + 'default': {'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'}, + 'other': { + 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', + 'LOCATION': 'other' + }, + }) def test_multiple_caches(self): "Check that multiple locmem caches are isolated" cache.set('value', 42) @@ -1139,6 +1145,12 @@ class CustomCacheKeyValidationTests(TestCase): self.assertEqual(cache.get(key), val) +@override_settings( + CACHES={ + 'default': { + 'BACKEND': 'cache.closeable_cache.CacheClass', + } + },) class GetCacheTests(IgnorePendingDeprecationWarningsMixin, TestCase): def test_simple(self): @@ -1157,6 +1169,12 @@ class GetCacheTests(IgnorePendingDeprecationWarningsMixin, TestCase): self.assertRaises(InvalidCacheBackendError, get_cache, 'does_not_exist') def test_close(self): + from django.core import signals + self.assertFalse(cache.closed) + signals.request_finished.send(self.__class__) + self.assertTrue(cache.closed) + + def test_close_deprecated(self): from django.core.cache import get_cache from django.core import signals cache = get_cache('cache.closeable_cache.CacheClass') |
