mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
fix for cache (#3538)
This commit is contained in:
@@ -259,3 +259,29 @@ def test_discard():
|
||||
cache.discard("key4") # key that does not exist
|
||||
|
||||
assert len(cache) == 2 # size should not change
|
||||
|
||||
|
||||
def test_discard_regression():
|
||||
"""Regression test for https://github.com/Textualize/textual/issues/3537"""
|
||||
|
||||
cache = LRUCache(maxsize=3)
|
||||
cache[1] = "foo"
|
||||
cache[2] = "bar"
|
||||
cache[3] = "baz"
|
||||
cache[4] = "egg"
|
||||
|
||||
assert cache.keys() == {2, 3, 4}
|
||||
|
||||
cache.discard(2)
|
||||
assert cache.keys() == {3, 4}
|
||||
|
||||
cache[5] = "bob"
|
||||
assert cache.keys() == {3, 4, 5}
|
||||
|
||||
cache.discard(5)
|
||||
assert cache.keys() == {3, 4}
|
||||
|
||||
cache.discard(4)
|
||||
cache.discard(3)
|
||||
|
||||
assert cache.keys() == set()
|
||||
|
||||
Reference in New Issue
Block a user