mirror of https://github.com/django/django.git
Fixed #26460 -- Issued a single warning for invalid cache key
This commit is contained in:
parent
15a20dc9af
commit
d356bb653f
|
@ -242,6 +242,7 @@ class BaseCache(object):
|
||||||
warnings.warn('Cache key contains characters that will cause '
|
warnings.warn('Cache key contains characters that will cause '
|
||||||
'errors if used with memcached: %r' % key,
|
'errors if used with memcached: %r' % key,
|
||||||
CacheKeyWarning)
|
CacheKeyWarning)
|
||||||
|
break
|
||||||
|
|
||||||
def incr_version(self, key, delta=1, version=None):
|
def incr_version(self, key, delta=1, version=None):
|
||||||
"""Adds delta to the cache version for the supplied key. Returns the
|
"""Adds delta to the cache version for the supplied key. Returns the
|
||||||
|
|
|
@ -586,7 +586,7 @@ class BaseCacheTests(object):
|
||||||
warnings.simplefilter("always")
|
warnings.simplefilter("always")
|
||||||
# memcached does not allow whitespace or control characters in keys
|
# memcached does not allow whitespace or control characters in keys
|
||||||
cache.set('key with spaces', 'value')
|
cache.set('key with spaces', 'value')
|
||||||
self.assertEqual(len(w), 2)
|
self.assertEqual(len(w), 1)
|
||||||
self.assertIsInstance(w[0].message, CacheKeyWarning)
|
self.assertIsInstance(w[0].message, CacheKeyWarning)
|
||||||
with warnings.catch_warnings(record=True) as w:
|
with warnings.catch_warnings(record=True) as w:
|
||||||
warnings.simplefilter("always")
|
warnings.simplefilter("always")
|
||||||
|
|
Loading…
Reference in New Issue