def test_infinite_retry(self): backoff = BackoffMock() # specify infinite retries, but give up after 5 retry = Retry(backoff, -1) with pytest.raises(ConnectionError): retry.call_with_retry(self._do, self._fail_inf) assert self.actual_attempts == 5 assert self.actual_failures == 5
def test_retry(self, retries): backoff = BackoffMock() retry = Retry(backoff, retries) with pytest.raises(ConnectionError): retry.call_with_retry(self._do, self._fail) assert self.actual_attempts == 1 + retries assert self.actual_failures == 1 + retries assert backoff.reset_calls == 1 assert backoff.calls == retries