| | 89 | def test_TrappedAndReRaiseFailure(self): |
| | 90 | """ |
| | 91 | If the failure doesn't match the error pre-defined, this test case will raise the same failure. |
| | 92 | """ |
| | 93 | exception = ValueError() |
| | 94 | try: |
| | 95 | raise exception |
| | 96 | except: |
| | 97 | f = failure.Failure() |
| | 98 | # On Python 2, the same failure is reraised: |
| | 99 | untrapped = self.assertRaises(failure.Failure, f.trap, OverflowError) |
| | 100 | self.assertIdentical(f, untrapped) |
| | 101 | |
| | 102 | |
| | 103 | def test_TrappedAndReRaiseException(self): |
| | 104 | """ |
| | 105 | If the failure doesn't match the error pre-defined, the underlying exception will be re-raised. |
| | 106 | """ |
| | 107 | exception = ValueError() |
| | 108 | try: |
| | 109 | raise exception |
| | 110 | except: |
| | 111 | f = failure.Failure() |
| | 112 | # On both Python 2 and Python 3, the underlying exception is passed |
| | 113 | # on: |
| | 114 | try: |
| | 115 | f.trap(OverflowError) |
| | 116 | except: |
| | 117 | untrapped = failure.Failure() |
| | 118 | self.assertIdentical(untrapped.value, exception) |
| | 119 | else: |
| | 120 | self.fail("Exception was not re-raised.") |
| | 121 | |
| | 122 | |