77 self.assertEqual(list(d), ['c', 'b', 'a']) |
77 self.assertEqual(list(d), ['c', 'b', 'a']) |
78 |
78 |
79 self.assertEqual(d.get('a'), 'va') |
79 self.assertEqual(d.get('a'), 'va') |
80 self.assertEqual(list(d), ['a', 'c', 'b']) |
80 self.assertEqual(list(d), ['a', 'c', 'b']) |
81 |
81 |
|
82 def testpeek(self): |
|
83 d = util.lrucachedict(4) |
|
84 d['a'] = 'va' |
|
85 d['b'] = 'vb' |
|
86 d['c'] = 'vc' |
|
87 |
|
88 with self.assertRaises(KeyError): |
|
89 d.peek('missing') |
|
90 self.assertEqual(list(d), ['c', 'b', 'a']) |
|
91 self.assertIsNone(d.peek('missing', None)) |
|
92 self.assertEqual(list(d), ['c', 'b', 'a']) |
|
93 |
|
94 self.assertEqual(d.peek('a'), 'va') |
|
95 self.assertEqual(list(d), ['c', 'b', 'a']) |
|
96 |
82 def testcopypartial(self): |
97 def testcopypartial(self): |
83 d = util.lrucachedict(4) |
98 d = util.lrucachedict(4) |
84 d.insert('a', 'va', cost=4) |
99 d.insert('a', 'va', cost=4) |
85 d.insert('b', 'vb', cost=2) |
100 d.insert('b', 'vb', cost=2) |
86 |
101 |