def test_no_sleep(self):
     r = Retrying()
     self.assertEqual(0, r.wait(18, 9879))
Пример #2
0
 def test_incrementing_sleep(self):
     r = Retrying(wait=tenacity.wait_incrementing(
         start=500, increment=100))
     self.assertEqual(500, r.wait(1, 6546))
     self.assertEqual(600, r.wait(2, 6546))
     self.assertEqual(700, r.wait(3, 6546))
Пример #3
0
 def test_fixed_sleep(self):
     r = Retrying(wait=tenacity.wait_fixed(1))
     self.assertEqual(1, r.wait(12, 6546))
Пример #4
0
 def test_wait_func(self):
     r = Retrying(wait=lambda attempt, delay: attempt * delay)
     self.assertEqual(r.wait(_make_wait_call_state(1, 5)), 5)
     self.assertEqual(r.wait(_make_wait_call_state(2, 11)), 22)
     self.assertEqual(r.wait(_make_wait_call_state(10, 100)), 1000)
Пример #5
0
 def test_wait_func(self):
     r = Retrying(wait=lambda attempt, delay: attempt * delay)
     self.assertEqual(r.wait(1, 5), 5)
     self.assertEqual(r.wait(2, 11), 22)
     self.assertEqual(r.wait(10, 100), 1000)
Пример #6
0
 def test_wait_jitter(self):
     r = Retrying(wait=tenacity.wait_jitter(3))
     # Test it a few time since it's random
     for i in six.moves.range(1000):
         self.assertLess(r.wait(1, 5), 3)