test_caching.py 文件源码

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

项目:qcore 作者: quora 项目源码 文件源码
def test_memoize():
    """Test Caching with no Time-To-Live (TTL)."""
    global x
    for fn in memoize_fns:
        x = 0
        assert_eq(4, fn(1))
        assert_eq(1, x)

        assert_eq(8, fn(2, 4))
        assert_eq(2, x)
        # should not result in another call
        assert_eq(8, fn(2, z=4))
        assert_eq(2, x)
        assert_eq(8, fn(y=2, z=4))
        assert_eq(2, x)

        fn.clear_cache()
        assert_eq(4, fn(1))
        assert_eq(3, x)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号