mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #16410 -- Fixed get_cache to behave gracefully when given a string that can't be split. Thanks, jedie.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16511 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
19
tests/regressiontests/cache/tests.py
vendored
19
tests/regressiontests/cache/tests.py
vendored
@@ -12,7 +12,7 @@ import warnings
|
||||
from django.conf import settings
|
||||
from django.core import management
|
||||
from django.core.cache import get_cache, DEFAULT_CACHE_ALIAS
|
||||
from django.core.cache.backends.base import CacheKeyWarning
|
||||
from django.core.cache.backends.base import CacheKeyWarning, InvalidCacheBackendError
|
||||
from django.db import connections, router
|
||||
from django.http import HttpResponse, HttpRequest, QueryDict
|
||||
from django.middleware.cache import FetchFromCacheMiddleware, UpdateCacheMiddleware, CacheMiddleware
|
||||
@@ -938,6 +938,23 @@ class CustomCacheKeyValidationTests(unittest.TestCase):
|
||||
cache.set(key, val)
|
||||
self.assertEqual(cache.get(key), val)
|
||||
|
||||
|
||||
class GetCacheTests(unittest.TestCase):
|
||||
|
||||
def test_simple(self):
|
||||
cache = get_cache('locmem://')
|
||||
from django.core.cache.backends.locmem import LocMemCache
|
||||
self.assertTrue(isinstance(cache, LocMemCache))
|
||||
|
||||
from django.core.cache import cache
|
||||
self.assertTrue(isinstance(cache, get_cache('default').__class__))
|
||||
|
||||
cache = get_cache(
|
||||
'django.core.cache.backends.dummy.DummyCache', **{'TIMEOUT': 120})
|
||||
self.assertEqual(cache.default_timeout, 120)
|
||||
|
||||
self.assertRaises(InvalidCacheBackendError, get_cache, 'does_not_exist')
|
||||
|
||||
class CacheUtils(unittest.TestCase):
|
||||
"""TestCase for django.utils.cache functions."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user