I am getting sucked during writing one of unit test, because one specific function doesn’t works. After huge time spending, it is revealed that I used lru_cache that’s why it just execute one time (could be by another TestCase).
But in the test environment I need fresh result instead of serving from cache for various reasons.
After googling finally I found out real application of cache invalidation. Bellows are example
from functools import lru_cache @lru_cache(maxsize=None) def my_function(arg1, arg2) return arg1 + arg2 # Clear Cache before calling my_function.cache_clear() my_function(2, 2)