test_caching.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:qcore 作者: quora 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号