quick fix to cached, adding a sanity test, fixes #12

This commit is contained in:
Mahmoud Hashemi 2015-04-10 09:22:15 -07:00
parent c6d1328ca2
commit 83bdff72d4
1 changed files with 11 additions and 1 deletions

View File

@ -416,10 +416,21 @@ def cached(cache, typed=False):
check. Default ``False``, setting to ``True`` causes the
cache keys for ``3`` and ``3.0`` to be considered unequal.
>>> my_cache = LRU()
>>> @cached(my_cache)
... def cached_lower(x):
... return x.lower()
...
>>> cached_lower("CaChInG's FuN AgAiN!")
"caching's fun again!"
>>> len(my_cache)
1
.. _hashable: https://docs.python.org/2/glossary.html#term-hashable
"""
def cached_func_decorator(func):
return CachedFunction(func, cache, typed=typed)
return cached_func_decorator
@ -445,4 +456,3 @@ if __name__ == '__main__':
_test_lri()
_test_lru()