def test_circuitbreaker_should_clear_last_exception_on_success_call(): cb = CircuitBreaker(name='Foobar') cb._last_failure = IOError() assert isinstance(cb.last_failure, IOError) cb.call(lambda: True) assert cb.last_failure is None
def test_circuitbreaker_error__str__(): cb = CircuitBreaker(name='Foobar') cb._last_failure = Exception() error = CircuitBreakerError(cb) assert str(error).startswith('Circuit "Foobar" OPEN until ') assert str(error).endswith( '(0 failures, 30 sec remaining) (last_failure: Exception())')