Exemple #1
0
 def test_has_key(self):
     for size in SIZES:
         l = TTLRU(size)
         for i in range(2 * size):
             l[i] = str(i)
             self.assertTrue(l.has_key(i))
         for i in range(size, 2 * size):
             self.assertTrue(l.has_key(i))
         for i in range(size):
             self.assertFalse(l.has_key(i))
Exemple #2
0
 def test_default_ttl(self):
     l = TTLRU(2, ttl=int(20e6))
     l[0] = 0
     l[1] = 1
     self.assertEqual(l[0], 0)
     self.assertEqual(l[1], 1)
     self.assertTrue(l.has_key(0))
     self.assertTrue(l.has_key(1))
     self.assertTrue(0 in l)
     self.assertTrue(1 in l)
     time.sleep(0.020)
     self.assertFalse(l.has_key(0))
     self.assertFalse(l.has_key(1))
     self.assertFalse(0 in l)
     self.assertFalse(1 in l)