Revision 506be7c5 test/ganeti.utils_unittest.py
b/test/ganeti.utils_unittest.py | ||
---|---|---|
1612 | 1612 |
def _RaiseRetryAgain(): |
1613 | 1613 |
raise utils.RetryAgain() |
1614 | 1614 |
|
1615 |
@staticmethod |
|
1616 |
def _RaiseRetryAgainWithArg(args): |
|
1617 |
raise utils.RetryAgain(*args) |
|
1618 |
|
|
1615 | 1619 |
def _WrongNestedLoop(self): |
1616 | 1620 |
return utils.Retry(self._RaiseRetryAgain, 0.01, 0.02) |
1617 | 1621 |
|
... | ... | |
1642 | 1646 |
except utils.RetryTimeout: |
1643 | 1647 |
self.fail("Didn't detect inner loop's exception") |
1644 | 1648 |
|
1649 |
def testTimeoutArgument(self): |
|
1650 |
retry_arg="my_important_debugging_message" |
|
1651 |
try: |
|
1652 |
utils.Retry(self._RaiseRetryAgainWithArg, 0.01, 0.02, args=[[retry_arg]]) |
|
1653 |
except utils.RetryTimeout, err: |
|
1654 |
self.failUnlessEqual(err.args, (retry_arg, )) |
|
1655 |
else: |
|
1656 |
self.fail("Expected timeout didn't happen") |
|
1657 |
|
|
1658 |
def testRaiseInnerWithExc(self): |
|
1659 |
retry_arg="my_important_debugging_message" |
|
1660 |
try: |
|
1661 |
try: |
|
1662 |
utils.Retry(self._RaiseRetryAgainWithArg, 0.01, 0.02, |
|
1663 |
args=[[errors.GenericError(retry_arg, retry_arg)]]) |
|
1664 |
except utils.RetryTimeout, err: |
|
1665 |
err.RaiseInner() |
|
1666 |
else: |
|
1667 |
self.fail("Expected timeout didn't happen") |
|
1668 |
except errors.GenericError, err: |
|
1669 |
self.failUnlessEqual(err.args, (retry_arg, retry_arg)) |
|
1670 |
else: |
|
1671 |
self.fail("Expected GenericError didn't happen") |
|
1672 |
|
|
1673 |
def testRaiseInnerWithMsg(self): |
|
1674 |
retry_arg="my_important_debugging_message" |
|
1675 |
try: |
|
1676 |
try: |
|
1677 |
utils.Retry(self._RaiseRetryAgainWithArg, 0.01, 0.02, |
|
1678 |
args=[[retry_arg, retry_arg]]) |
|
1679 |
except utils.RetryTimeout, err: |
|
1680 |
err.RaiseInner() |
|
1681 |
else: |
|
1682 |
self.fail("Expected timeout didn't happen") |
|
1683 |
except utils.RetryTimeout, err: |
|
1684 |
self.failUnlessEqual(err.args, (retry_arg, retry_arg)) |
|
1685 |
else: |
|
1686 |
self.fail("Expected RetryTimeout didn't happen") |
|
1687 |
|
|
1645 | 1688 |
|
1646 | 1689 |
class TestLineSplitter(unittest.TestCase): |
1647 | 1690 |
def test(self): |
Also available in: Unified diff