Skip to content
Snippets Groups Projects
Commit 7ab9f91a authored by Paul "LeoNerd" Evans's avatar Paul "LeoNerd" Evans
Browse files

Unit-test that Cache() key eviction is ordered

parent ed008e85
No related branches found
No related tags found
No related merge requests found
...@@ -51,6 +51,24 @@ class CacheTestCase(unittest.TestCase): ...@@ -51,6 +51,24 @@ class CacheTestCase(unittest.TestCase):
self.assertTrue(failed) self.assertTrue(failed)
def test_eviction(self):
cache = Cache("test", max_entries=2)
cache.prefill(1, "one")
cache.prefill(2, "two")
cache.prefill(3, "three") # 1 will be evicted
failed = False
try:
cache.get(1)
except KeyError:
failed = True
self.assertTrue(failed)
cache.get(2)
cache.get(3)
class CacheDecoratorTestCase(unittest.TestCase): class CacheDecoratorTestCase(unittest.TestCase):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment