Пример #1
0
 def test_bucket(self):
     bucket = Bucket(100, 1000)
     self.assertEqual(bucket.get(), 1000)
     time.sleep(0.1)
     self.assertEqual(bucket.get(), 1000)
     bucket.desc(100)
     self.assertEqual(bucket.get(), 900)
     time.sleep(0.1)
     self.assertAlmostEqual(bucket.get(), 910, delta=2)
     time.sleep(0.1)
     self.assertAlmostEqual(bucket.get(), 920, delta=2)
Пример #2
0
 def test_bucket(self):
     bucket = Bucket(100, 1000)
     self.assertEqual(bucket.get(), 1000)
     time.sleep(0.1)
     self.assertEqual(bucket.get(), 1000)
     bucket.desc(100)
     self.assertEqual(bucket.get(), 900)
     time.sleep(0.1)
     self.assertAlmostEqual(bucket.get(), 910, delta=2)
     time.sleep(0.1)
     self.assertAlmostEqual(bucket.get(), 920, delta=2)