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()
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")