Fixed #4041 -- Added a __contains__ method to cache backends. Thanks, Gary
Wilson and SmileyChris. git-svn-id: http://code.djangoproject.com/svn/django/trunk@5171 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
d1b0d34dc6
commit
0839a0046a
|
@ -54,3 +54,6 @@ class BaseCache(object):
|
|||
Returns True if the key is in the cache and has not expired.
|
||||
"""
|
||||
return self.get(key) is not None
|
||||
|
||||
__contains__ = has_key
|
||||
|
||||
|
|
|
@ -46,6 +46,11 @@ class Cache(unittest.TestCase):
|
|||
self.assertEqual(cache.has_key("hello"), True)
|
||||
self.assertEqual(cache.has_key("goodbye"), False)
|
||||
|
||||
def test_in(self):
|
||||
cache.set("hello", "goodbye")
|
||||
self.assertEqual("hello" in cache, True)
|
||||
self.assertEqual("goodbye" in cache, False)
|
||||
|
||||
def test_data_types(self):
|
||||
# test data types
|
||||
stuff = {
|
||||
|
|
Loading…
Reference in New Issue