Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
for i in range(3):
try:
breaker()
except AssertionError:
self.assertTrue(breaker.is_ready())
else:
self.fail('Should have raised an exception')
try:
breaker()
except AssertionError:
self.assertFalse(breaker.is_ready())
else:
self.fail('Should have raised an exception')
try:
breaker()
except CircuitOpen:
pass
else:
self.fail('Wrong exception?')
breaker.error_expiration = datetime.datetime.now()
try:
breaker()
except:
pass
self.assertFalse(breaker.is_ready()) #we failed so we're not ready yet
breaker.fail = False
breaker.error_expiration = datetime.datetime.now()
breaker()
self.assertTrue(breaker.is_ready())