Revision 1b429e2a test/ganeti.utils_unittest.py

b/test/ganeti.utils_unittest.py
1535 1535
    self.assert_(os.path.isdir(path))
1536 1536

  
1537 1537

  
1538
class TestRetry(testutils.GanetiTestCase):
1539
  @staticmethod
1540
  def _RaiseRetryAgain():
1541
    raise utils.RetryAgain()
1542

  
1543
  def _WrongNestedLoop(self):
1544
    return utils.Retry(self._RaiseRetryAgain, 0.01, 0.02)
1545

  
1546
  def testRaiseTimeout(self):
1547
    self.failUnlessRaises(utils.RetryTimeout, utils.Retry,
1548
                          self._RaiseRetryAgain, 0.01, 0.02)
1549

  
1550
  def testComplete(self):
1551
    self.failUnlessEqual(utils.Retry(lambda: True, 0, 1), True)
1552

  
1553
  def testNestedLoop(self):
1554
    try:
1555
      self.failUnlessRaises(errors.ProgrammerError, utils.Retry,
1556
                            self._WrongNestedLoop, 0, 1)
1557
    except utils.RetryTimeout:
1558
      self.fail("Didn't detect inner loop's exception")
1559

  
1560

  
1538 1561
if __name__ == '__main__':
1539 1562
  testutils.GanetiTestProgram()

Also available in: Unified diff