def test_retry_on_custom_exception(self): failing_operation = create_failing_operation() retries = 3 policy = RetryPolicy(retries, [SomeRetriableException]) failsafe = Failsafe(retry_policy=policy) assert failing_operation.called == 0 with pytest.raises(RetriesExhausted): loop.run_until_complete(failsafe.run(failing_operation)) assert failing_operation.called == retries + 1
def test_retry_four_times(self): failing_operation = create_failing_operation() expected_attempts = 5 retries = 4 policy = RetryPolicy(retries) failsafe = Failsafe(retry_policy=policy) assert failing_operation.called == 0 with pytest.raises(RetriesExhausted): loop.run_until_complete(failsafe.run(failing_operation)) assert failing_operation.called == expected_attempts