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
ファイル: test_util_retry.py プロジェクト: B-Rich/build-tools
 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
ファイル: test_util_retry.py プロジェクト: B-Rich/build-tools
 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
ファイル: test_util_retry.py プロジェクト: B-Rich/build-tools
 def testRetriableSelectiveExceptionFail(self):
     func = retriable(attempts=2, sleeptime=0,
                      retry_exceptions=(OtherError,))(_raiseCustomException)
     self.assertRaises(NewError, func)
コード例 #10
0
ファイル: test_util_retry.py プロジェクト: B-Rich/build-tools
 def testRetriableSelectiveExceptionSucceed(self):
     func = retriable(attempts=2, sleeptime=0,
                      retry_exceptions=(NewError,))(_raiseCustomException)
     func()
コード例 #11
0
ファイル: test_util_retry.py プロジェクト: B-Rich/build-tools
 def testRetriableFailEnsureRaisesLastException(self):
     func = retriable(sleeptime=0)(_alwaysFail)
     self.assertRaises(Exception, func)
コード例 #12
0
ファイル: test_util_retry.py プロジェクト: B-Rich/build-tools
 def testRetriableFailWithoutCatching(self):
     func = retriable(sleeptime=0)(_alwaysFail)
     self.assertRaises(Exception, func, retry_exceptions=())
コード例 #13
0
ファイル: test_util_retry.py プロジェクト: B-Rich/build-tools
 def testRetriableSucceed(self):
     func = retriable(attempts=2, sleeptime=0)(_succeedOnSecondAttempt)
     func()
コード例 #14
0
ファイル: test_util_retry.py プロジェクト: B-Rich/build-tools
 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
ファイル: test_util_retry.py プロジェクト: B-Rich/build-tools
 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
ファイル: test_util_retry.py プロジェクト: B-Rich/build-tools
 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)