Skip to content

back to Claude Sonnet 3.5 - Base summary

Claude Sonnet 3.5 - Base: cachetools

Pytest Summary for test tests

status count
passed 173
failed 42
total 215
collected 215

Failed pytests:

test_cached.py::CacheWrapperTest::test_decorator_typed

test_cached.py::CacheWrapperTest::test_decorator_typed
self = 

    def test_decorator_typed(self):
        cache = self.cache(3)
        key = cachetools.keys.typedkey
        wrapper = cachetools.cached(cache, key=key)(self.func)

        self.assertEqual(len(cache), 0)
        self.assertEqual(wrapper(0), 0)
        self.assertEqual(len(cache), 1)
        self.assertIn(cachetools.keys.typedkey(0), cache)
>       self.assertNotIn(cachetools.keys.typedkey(1), cache)
E       AssertionError: (,) unexpectedly found in Cache({(,): 0}, maxsize=3, currsize=1)

tests/test_cached.py:64: AssertionError

test_cached.py::DictWrapperTest::test_decorator_typed

test_cached.py::DictWrapperTest::test_decorator_typed
self = 

    def test_decorator_typed(self):
        cache = self.cache(3)
        key = cachetools.keys.typedkey
        wrapper = cachetools.cached(cache, key=key)(self.func)

        self.assertEqual(len(cache), 0)
        self.assertEqual(wrapper(0), 0)
        self.assertEqual(len(cache), 1)
        self.assertIn(cachetools.keys.typedkey(0), cache)
>       self.assertNotIn(cachetools.keys.typedkey(1), cache)
E       AssertionError: (,) unexpectedly found in {(,): 0}

tests/test_cached.py:64: AssertionError

test_cachedmethod.py::CachedMethodTest::test_typedmethod_dict

test_cachedmethod.py::CachedMethodTest::test_typedmethod_dict
self = 

    def test_typedmethod_dict(self):
        cached = Cached(LRUCache(maxsize=2))

        self.assertEqual(cached.get_typedmethod(0), 0)
>       self.assertEqual(cached.get_typedmethod(1), 1)
E       AssertionError: 0 != 1

tests/test_cachedmethod.py:74: AssertionError

test_cachedmethod.py::CachedMethodTest::test_typedmethod_lru

test_cachedmethod.py::CachedMethodTest::test_typedmethod_lru
self = 

    def test_typedmethod_lru(self):
        cached = Cached(LRUCache(maxsize=2))

        self.assertEqual(cached.get_typedmethod(0), 0)
>       self.assertEqual(cached.get_typedmethod(1), 1)
E       AssertionError: 0 != 1

tests/test_cachedmethod.py:97: AssertionError

test_func.py::FIFODecoratorTest::test_decorator

test_func.py::FIFODecoratorTest::test_decorator
self = 

    def test_decorator(self):
        cached = self.decorator(maxsize=2)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 2, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:12: AttributeError

test_func.py::FIFODecoratorTest::test_decorator_clear

test_func.py::FIFODecoratorTest::test_decorator_clear
self = 

    def test_decorator_clear(self):
        cached = self.decorator(maxsize=2)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 2, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:23: AttributeError

test_func.py::FIFODecoratorTest::test_decorator_nocache

test_func.py::FIFODecoratorTest::test_decorator_nocache
self = 

    def test_decorator_nocache(self):
        cached = self.decorator(maxsize=0)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 0, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:34: AttributeError

test_func.py::FIFODecoratorTest::test_decorator_typed

test_func.py::FIFODecoratorTest::test_decorator_typed
self = 

    def test_decorator_typed(self):
        cached = self.decorator(maxsize=2, typed=True)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 2, "typed": True})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:56: AttributeError

test_func.py::FIFODecoratorTest::test_decorator_unbound

test_func.py::FIFODecoratorTest::test_decorator_unbound
self = 

    def test_decorator_unbound(self):
        cached = self.decorator(maxsize=None)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": None, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:45: AttributeError

test_func.py::FIFODecoratorTest::test_decorator_user_function

test_func.py::FIFODecoratorTest::test_decorator_user_function
self = 

    def test_decorator_user_function(self):
        cached = self.decorator(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 128, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:69: AttributeError

test_func.py::LFUDecoratorTest::test_decorator

test_func.py::LFUDecoratorTest::test_decorator
self = 

    def test_decorator(self):
        cached = self.decorator(maxsize=2)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 2, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:12: AttributeError

test_func.py::LFUDecoratorTest::test_decorator_clear

test_func.py::LFUDecoratorTest::test_decorator_clear
self = 

    def test_decorator_clear(self):
        cached = self.decorator(maxsize=2)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 2, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:23: AttributeError

test_func.py::LFUDecoratorTest::test_decorator_nocache

test_func.py::LFUDecoratorTest::test_decorator_nocache
self = 

    def test_decorator_nocache(self):
        cached = self.decorator(maxsize=0)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 0, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:34: AttributeError

test_func.py::LFUDecoratorTest::test_decorator_typed

test_func.py::LFUDecoratorTest::test_decorator_typed
self = 

    def test_decorator_typed(self):
        cached = self.decorator(maxsize=2, typed=True)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 2, "typed": True})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:56: AttributeError

test_func.py::LFUDecoratorTest::test_decorator_unbound

test_func.py::LFUDecoratorTest::test_decorator_unbound
self = 

    def test_decorator_unbound(self):
        cached = self.decorator(maxsize=None)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": None, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:45: AttributeError

test_func.py::LFUDecoratorTest::test_decorator_user_function

test_func.py::LFUDecoratorTest::test_decorator_user_function
self = 

    def test_decorator_user_function(self):
        cached = self.decorator(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 128, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:69: AttributeError

test_func.py::LRUDecoratorTest::test_decorator

test_func.py::LRUDecoratorTest::test_decorator
self = 

    def test_decorator(self):
        cached = self.decorator(maxsize=2)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 2, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:12: AttributeError

test_func.py::LRUDecoratorTest::test_decorator_clear

test_func.py::LRUDecoratorTest::test_decorator_clear
self = 

    def test_decorator_clear(self):
        cached = self.decorator(maxsize=2)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 2, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:23: AttributeError

test_func.py::LRUDecoratorTest::test_decorator_nocache

test_func.py::LRUDecoratorTest::test_decorator_nocache
self = 

    def test_decorator_nocache(self):
        cached = self.decorator(maxsize=0)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 0, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:34: AttributeError

test_func.py::LRUDecoratorTest::test_decorator_typed

test_func.py::LRUDecoratorTest::test_decorator_typed
self = 

    def test_decorator_typed(self):
        cached = self.decorator(maxsize=2, typed=True)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 2, "typed": True})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:56: AttributeError

test_func.py::LRUDecoratorTest::test_decorator_unbound

test_func.py::LRUDecoratorTest::test_decorator_unbound
self = 

    def test_decorator_unbound(self):
        cached = self.decorator(maxsize=None)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": None, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:45: AttributeError

test_func.py::LRUDecoratorTest::test_decorator_user_function

test_func.py::LRUDecoratorTest::test_decorator_user_function
self = 

    def test_decorator_user_function(self):
        cached = self.decorator(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 128, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:69: AttributeError

test_func.py::MRUDecoratorTest::test_decorator

test_func.py::MRUDecoratorTest::test_decorator
self = 

    def test_decorator(self):
        cached = self.decorator(maxsize=2)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 2, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:12: AttributeError

test_func.py::MRUDecoratorTest::test_decorator_clear

test_func.py::MRUDecoratorTest::test_decorator_clear
self = 

    def test_decorator_clear(self):
        cached = self.decorator(maxsize=2)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 2, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:23: AttributeError

test_func.py::MRUDecoratorTest::test_decorator_nocache

test_func.py::MRUDecoratorTest::test_decorator_nocache
self = 

    def test_decorator_nocache(self):
        cached = self.decorator(maxsize=0)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 0, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:34: AttributeError

test_func.py::MRUDecoratorTest::test_decorator_typed

test_func.py::MRUDecoratorTest::test_decorator_typed
self = 

    def test_decorator_typed(self):
        cached = self.decorator(maxsize=2, typed=True)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 2, "typed": True})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:56: AttributeError

test_func.py::MRUDecoratorTest::test_decorator_unbound

test_func.py::MRUDecoratorTest::test_decorator_unbound
self = 

    def test_decorator_unbound(self):
        cached = self.decorator(maxsize=None)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": None, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:45: AttributeError

test_func.py::MRUDecoratorTest::test_decorator_user_function

test_func.py::MRUDecoratorTest::test_decorator_user_function
self = 

    def test_decorator_user_function(self):
        cached = self.decorator(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 128, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:69: AttributeError

test_func.py::RRDecoratorTest::test_decorator

test_func.py::RRDecoratorTest::test_decorator
self = 

    def test_decorator(self):
        cached = self.decorator(maxsize=2)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 2, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:12: AttributeError

test_func.py::RRDecoratorTest::test_decorator_clear

test_func.py::RRDecoratorTest::test_decorator_clear
self = 

    def test_decorator_clear(self):
        cached = self.decorator(maxsize=2)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 2, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:23: AttributeError

test_func.py::RRDecoratorTest::test_decorator_nocache

test_func.py::RRDecoratorTest::test_decorator_nocache
self = 

    def test_decorator_nocache(self):
        cached = self.decorator(maxsize=0)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 0, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:34: AttributeError

test_func.py::RRDecoratorTest::test_decorator_typed

test_func.py::RRDecoratorTest::test_decorator_typed
self = 

    def test_decorator_typed(self):
        cached = self.decorator(maxsize=2, typed=True)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 2, "typed": True})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:56: AttributeError

test_func.py::RRDecoratorTest::test_decorator_unbound

test_func.py::RRDecoratorTest::test_decorator_unbound
self = 

    def test_decorator_unbound(self):
        cached = self.decorator(maxsize=None)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": None, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:45: AttributeError

test_func.py::RRDecoratorTest::test_decorator_user_function

test_func.py::RRDecoratorTest::test_decorator_user_function
self = 

    def test_decorator_user_function(self):
        cached = self.decorator(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 128, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:69: AttributeError

test_func.py::TTLDecoratorTest::test_decorator

test_func.py::TTLDecoratorTest::test_decorator
self = 

    def test_decorator(self):
        cached = self.decorator(maxsize=2)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 2, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:12: AttributeError

test_func.py::TTLDecoratorTest::test_decorator_clear

test_func.py::TTLDecoratorTest::test_decorator_clear
self = 

    def test_decorator_clear(self):
        cached = self.decorator(maxsize=2)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 2, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:23: AttributeError

test_func.py::TTLDecoratorTest::test_decorator_nocache

test_func.py::TTLDecoratorTest::test_decorator_nocache
self = 

    def test_decorator_nocache(self):
        cached = self.decorator(maxsize=0)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 0, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:34: AttributeError

test_func.py::TTLDecoratorTest::test_decorator_typed

test_func.py::TTLDecoratorTest::test_decorator_typed
self = 

    def test_decorator_typed(self):
        cached = self.decorator(maxsize=2, typed=True)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 2, "typed": True})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:56: AttributeError

test_func.py::TTLDecoratorTest::test_decorator_unbound

test_func.py::TTLDecoratorTest::test_decorator_unbound
self = 

    def test_decorator_unbound(self):
        cached = self.decorator(maxsize=None)(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": None, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:45: AttributeError

test_func.py::TTLDecoratorTest::test_decorator_user_function

test_func.py::TTLDecoratorTest::test_decorator_user_function
self = 

    def test_decorator_user_function(self):
        cached = self.decorator(lambda n: n)
>       self.assertEqual(cached.cache_parameters(), {"maxsize": 128, "typed": False})
E       AttributeError: 'function' object has no attribute 'cache_parameters'

tests/test_func.py:69: AttributeError

test_keys.py::CacheKeysTest::test_typedkey

test_keys.py::CacheKeysTest::test_typedkey
self = 
key = 

    def test_typedkey(self, key=cachetools.keys.typedkey):
        self.assertEqual(key(), key())
        self.assertEqual(hash(key()), hash(key()))
        self.assertEqual(key(1, 2, 3), key(1, 2, 3))
        self.assertEqual(hash(key(1, 2, 3)), hash(key(1, 2, 3)))
        self.assertEqual(key(1, 2, 3, x=0), key(1, 2, 3, x=0))
        self.assertEqual(hash(key(1, 2, 3, x=0)), hash(key(1, 2, 3, x=0)))
>       self.assertNotEqual(key(1, 2, 3), key(3, 2, 1))
E       AssertionError: (, , ) == (, , )

tests/test_keys.py:49: AssertionError

test_keys.py::CacheKeysTest::test_typedmethodkey

test_keys.py::CacheKeysTest::test_typedmethodkey
self = 
key = 

    def test_typedmethodkey(self, key=cachetools.keys.typedmethodkey):
        # similar to typedkey(), but ignores its first positional argument
        self.assertEqual(key("x"), key("y"))
        self.assertEqual(hash(key("x")), hash(key("y")))
        self.assertEqual(key("x", 1, 2, 3), key("y", 1, 2, 3))
        self.assertEqual(hash(key("x", 1, 2, 3)), hash(key("y", 1, 2, 3)))
        self.assertEqual(key("x", 1, 2, 3, x=0), key("y", 1, 2, 3, x=0))
        self.assertEqual(hash(key("x", 1, 2, 3, x=0)), hash(key("y", 1, 2, 3, x=0)))
>       self.assertNotEqual(key("x", 1, 2, 3), key("x", 3, 2, 1))
E       AssertionError: (, , , ) == (, , , )

tests/test_keys.py:66: AssertionError

Patch diff

diff --git a/src/cachetools/func.py b/src/cachetools/func.py
index 338ef94..d5b9f85 100644
--- a/src/cachetools/func.py
+++ b/src/cachetools/func.py
@@ -25,7 +25,11 @@ def fifo_cache(maxsize=128, typed=False):
     algorithm.

     """
-    pass
+    if typed:
+        key = keys.typedkey
+    else:
+        key = keys.hashkey
+    return cached(cache=FIFOCache(maxsize), key=key)


 def lfu_cache(maxsize=128, typed=False):
@@ -34,7 +38,11 @@ def lfu_cache(maxsize=128, typed=False):
     algorithm.

     """
-    pass
+    if typed:
+        key = keys.typedkey
+    else:
+        key = keys.hashkey
+    return cached(cache=LFUCache(maxsize), key=key)


 def lru_cache(maxsize=128, typed=False):
@@ -43,7 +51,11 @@ def lru_cache(maxsize=128, typed=False):
     algorithm.

     """
-    pass
+    if typed:
+        key = keys.typedkey
+    else:
+        key = keys.hashkey
+    return cached(cache=LRUCache(maxsize), key=key)


 def mru_cache(maxsize=128, typed=False):
@@ -51,7 +63,11 @@ def mru_cache(maxsize=128, typed=False):
     up to `maxsize` results based on a Most Recently Used (MRU)
     algorithm.
     """
-    pass
+    if typed:
+        key = keys.typedkey
+    else:
+        key = keys.hashkey
+    return cached(cache=MRUCache(maxsize), key=key)


 def rr_cache(maxsize=128, choice=random.choice, typed=False):
@@ -60,7 +76,11 @@ def rr_cache(maxsize=128, choice=random.choice, typed=False):
     algorithm.

     """
-    pass
+    if typed:
+        key = keys.typedkey
+    else:
+        key = keys.hashkey
+    return cached(cache=RRCache(maxsize, choice=choice), key=key)


 def ttl_cache(maxsize=128, ttl=600, timer=time.monotonic, typed=False):
@@ -68,4 +88,8 @@ def ttl_cache(maxsize=128, ttl=600, timer=time.monotonic, typed=False):
     up to `maxsize` results based on a Least Recently Used (LRU)
     algorithm with a per-item time-to-live (TTL) value.
     """
-    pass
+    if typed:
+        key = keys.typedkey
+    else:
+        key = keys.hashkey
+    return cached(cache=TTLCache(maxsize, ttl, timer=timer), key=key)
diff --git a/src/cachetools/keys.py b/src/cachetools/keys.py
index ed97ffd..700885c 100644
--- a/src/cachetools/keys.py
+++ b/src/cachetools/keys.py
@@ -32,19 +32,29 @@ _kwmark = _HashedTuple,

 def hashkey(*args, **kwargs):
     """Return a cache key for the specified hashable arguments."""
-    pass
+    key = args
+    if kwargs:
+        key += (_kwmark,)
+        for item in kwargs.items():
+            key += item
+    return _HashedTuple(key)


 def methodkey(self, *args, **kwargs):
     """Return a cache key for use with cached methods."""
-    pass
+    return hashkey(self.__class__, *args, **kwargs)


 def typedkey(*args, **kwargs):
     """Return a typed cache key for the specified hashable arguments."""
-    pass
+    key = tuple(type(arg) for arg in args)
+    if kwargs:
+        key += (_kwmark,)
+        for item in kwargs.items():
+            key += (item[0], type(item[1]))
+    return _HashedTuple(key)


 def typedmethodkey(self, *args, **kwargs):
     """Return a typed cache key for use with cached methods."""
-    pass
+    return typedkey(self.__class__, *args, **kwargs)