def test_getitem(self): c = LRUCache(3) c[0] = 'a' c[1] = 'b' c[2] = 'c' assert_eq(3, c.get_capacity()) self._check_order([(0, 'a'), (1, 'b'), (2, 'c')], c) # Getting a value should make it MRU assert_eq('b', c[1]) self._check_order([(0, 'a'), (2, 'c'), (1, 'b')], c) # Missing value should fail with AssertRaises(KeyError): c[100]
def test_getitem(self): c = LRUCache(3) c[0] = "a" c[1] = "b" c[2] = "c" assert_eq(3, c.get_capacity()) self._check_order([(0, "a"), (1, "b"), (2, "c")], c) # Getting a value should make it MRU assert_eq("b", c[1]) self._check_order([(0, "a"), (2, "c"), (1, "b")], c) # Missing value should fail with AssertRaises(KeyError): c[100]