def test_memoize_with_ttl_unhashable():
"""Test Caching with TTL using dictionary arguments."""
global x
x = 0
assert_eq(12, cached_fn_with_ttl_unhashable(2))
assert_eq(1, x)
assert_eq(10, cached_fn_with_ttl_unhashable(1, z={'a': 2, 'b': 3, 'c': 5}))
assert_eq(2, x)
# should not result in another call
assert_eq(10, cached_fn_with_ttl_unhashable(1, z={'a': 2, 'b': 3, 'c': 5}))
assert_eq(2, x)
assert_eq(12, cached_fn_with_ttl_unhashable(2, z={'a': 1, 'b': 2, 'c': 3}))
assert_eq(2, x)
cached_fn_with_ttl_unhashable.clear_cache()
assert_eq(12, cached_fn_with_ttl_unhashable(2))
assert_eq(3, x)
评论列表
文章目录