

def test_backoff(self):
    ' Backoff is computed correctly '
    max_backoff = Retry.BACKOFF_MAX
    retry = Retry(total=100, backoff_factor=0.2)
    self.assertEqual(retry.get_backoff_time(), 0)
    retry = retry.increment()
    self.assertEqual(retry.get_backoff_time(), 0)
    retry = retry.increment()
    self.assertEqual(retry.backoff_factor, 0.2)
    self.assertEqual(retry.total, 98)
    self.assertEqual(retry.get_backoff_time(), 0.4)
    retry = retry.increment()
    self.assertEqual(retry.get_backoff_time(), 0.8)
    retry = retry.increment()
    self.assertEqual(retry.get_backoff_time(), 1.6)
    for i in xrange(10):
        retry = retry.increment()
    self.assertEqual(retry.get_backoff_time(), max_backoff)

dataset/ETHPy150Open shazow/urllib3/test/test_retry.py RetryTest.test_backoff/original