ipwnponies/pytest-antilru

Feature request: support for functools.cache

Closed this issue · 2 comments

I use @cache in places, and would love to use this plugin to clear those caches between tests. Is that something that has a place in this project?

Okay, nevermind. It already seems to do the trick. I guess functools.cache uses lrucache under the hood? :)

https://github.com/python/cpython/blob/3.9/Lib/functools.py#L652

def cache(user_function, /):
    'Simple lightweight unbounded cache.  Sometimes called "memoize".'
    return lru_cache(maxsize=None)(user_function)

It's basically functools.partial() on lru_cache 😄