コード例 #1
0
ファイル: test_fs.py プロジェクト: olirice/cachetools_ext
def test_popitem():
    cache = FSLRUCache(maxsize=3, clear_on_start=True)
    cache["hello"] = "world"
    cache["foo"] = "bar"
    key, val = cache.popitem()
    assert (key, val) == ("hello", "world")
    assert len(cache) == 1

    with pytest.raises(KeyError):
        cache.popitem()
        cache.popitem()
コード例 #2
0
def test_last_access_update():
    cache = FSLRUCache(maxsize=3, clear_on_start=True)
    cache["hello"] = "world"
    cache["foo"] = "bar"

    # Access "hello" to make "foo" the oldest key to be accessed
    cache["hello"]

    key, val = cache.popitem()
    assert (key, val) == ("foo", "bar")