tests/test-lrucachedict.py
changeset 40880 7cda0cacbbf6
parent 40879 0c638ff69f5c
child 43076 2372284d9457
equal deleted inserted replaced
40879:0c638ff69f5c 40880:7cda0cacbbf6
    92         self.assertEqual(list(d), ['c', 'b', 'a'])
    92         self.assertEqual(list(d), ['c', 'b', 'a'])
    93 
    93 
    94         self.assertEqual(d.peek('a'), 'va')
    94         self.assertEqual(d.peek('a'), 'va')
    95         self.assertEqual(list(d), ['c', 'b', 'a'])
    95         self.assertEqual(list(d), ['c', 'b', 'a'])
    96 
    96 
       
    97     def testpop(self):
       
    98         d = util.lrucachedict(4)
       
    99         d['a'] = 'va'
       
   100         d['b'] = 'vb'
       
   101         d['c'] = 'vc'
       
   102 
       
   103         with self.assertRaises(KeyError):
       
   104             d.pop('missing')
       
   105         self.assertEqual(list(d), ['c', 'b', 'a'])
       
   106         self.assertIsNone(d.pop('missing', None))
       
   107         self.assertEqual(list(d), ['c', 'b', 'a'])
       
   108 
       
   109         self.assertEqual(d.pop('b'), 'vb')
       
   110         self.assertEqual(list(d), ['c', 'a'])
       
   111 
    97     def testcopypartial(self):
   112     def testcopypartial(self):
    98         d = util.lrucachedict(4)
   113         d = util.lrucachedict(4)
    99         d.insert('a', 'va', cost=4)
   114         d.insert('a', 'va', cost=4)
   100         d.insert('b', 'vb', cost=2)
   115         d.insert('b', 'vb', cost=2)
   101 
   116