def testRetriableArgsPassed(self):
     args = (1, 'two', 3)
     kwargs = dict(foo='a', bar=7)
     func = retriable(sleeptime=0, jitter=0)(_mirrorArgs)
     ret = func(*args, **kwargs)
     self.assertEqual(ret[0], args)
     self.assertEqual(ret[1], kwargs)
Пример #2
0
 def testRetriableArgsPassed(self):
     args = (1, 'two', 3)
     kwargs = dict(foo='a', bar=7)
     func = retriable(sleeptime=0)(_mirrorArgs)
     ret = func(*args, **kwargs)
     self.assertEqual(ret[0], args)
     self.assertEqual(ret[1], kwargs)
 def testRetriableCleanupIsCalled(self):
     cleanup = mock.Mock()
     func = retriable(cleanup=cleanup, sleeptime=0,
                      jitter=0)(_succeedOnSecondAttempt)
     func()
     self.assertEquals(cleanup.call_count, 1)
 def testRetriableReturns(self):
     func = retriable(sleeptime=0, jitter=0)(_alwaysPass)
     ret = func()
     self.assertEquals(ret, True)
 def testRetriableOnlyRunOnce(self):
     global ATTEMPT_N
     func = retriable(attempts=3, sleeptime=0, jitter=0)(_alwaysPass)
     func()
     # ATTEMPT_N gets increased regardless of pass/fail
     self.assertEquals(2, ATTEMPT_N)
 def testRetriableWithSleep(self):
     func = retriable(attempts=2, sleeptime=1)(_succeedOnSecondAttempt)
     func()
Пример #7
0
 def testRetriableReturns(self):
     func = retriable(sleeptime=0)(_alwaysPass)
     ret = func()
     self.assertEquals(ret, True)
 def testRetriableFailEnsureRaisesLastException(self):
     func = retriable(sleeptime=0)(_alwaysFail)
     self.assertRaises(Exception, func)
Пример #9
0
 def testRetriableSelectiveExceptionFail(self):
     func = retriable(attempts=2, sleeptime=0,
                      retry_exceptions=(OtherError,))(_raiseCustomException)
     self.assertRaises(NewError, func)
Пример #10
0
 def testRetriableSelectiveExceptionSucceed(self):
     func = retriable(attempts=2, sleeptime=0,
                      retry_exceptions=(NewError,))(_raiseCustomException)
     func()
Пример #11
0
 def testRetriableFailEnsureRaisesLastException(self):
     func = retriable(sleeptime=0)(_alwaysFail)
     self.assertRaises(Exception, func)
Пример #12
0
 def testRetriableFailWithoutCatching(self):
     func = retriable(sleeptime=0)(_alwaysFail)
     self.assertRaises(Exception, func, retry_exceptions=())
Пример #13
0
 def testRetriableSucceed(self):
     func = retriable(attempts=2, sleeptime=0)(_succeedOnSecondAttempt)
     func()
Пример #14
0
 def testRetriableCleanupIsCalled(self):
     cleanup = mock.Mock()
     func = retriable(cleanup=cleanup, sleeptime=0)(_succeedOnSecondAttempt)
     func()
     self.assertEquals(cleanup.call_count, 1)
 def testRetriableSucceed(self):
     func = retriable(attempts=2, sleeptime=0,
                      jitter=0)(_succeedOnSecondAttempt)
     func()
Пример #16
0
 def testRetriableWithSleep(self):
     func = retriable(attempts=2, sleeptime=1)(_succeedOnSecondAttempt)
     func()
 def testRetriableFailWithoutCatching(self):
     func = retriable(sleeptime=0)(_alwaysFail)
     self.assertRaises(Exception, func, retry_exceptions=())
 def testRetriableSelectiveExceptionFail(self):
     func = retriable(
         attempts=2, sleeptime=0, jitter=0,
         retry_exceptions=(OtherError, ))(_raiseCustomException)
     self.assertRaises(NewError, func)
 def testRetriableSelectiveExceptionSucceed(self):
     func = retriable(attempts=2,
                      sleeptime=0,
                      jitter=0,
                      retry_exceptions=(NewError, ))(_raiseCustomException)
     func()
Пример #20
0
 def testRetriableOnlyRunOnce(self):
     global ATTEMPT_N
     func = retriable(attempts=3, sleeptime=0)(_alwaysPass)
     func()
     # ATTEMPT_N gets increased regardless of pass/fail
     self.assertEquals(2, ATTEMPT_N)