Ticket #5952: patch1.patch

File patch1.patch, 1.7 KB (added by sreepriya, 3 years ago)

This patch breaks the method names test_notTrapped into two methods and docstring added for both. The Comment11 review changes are implemented.

  • test_failure.py

     
    8686            self.fail("Exception was not re-raised.")
    8787
    8888
     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
    89123    def assertStartsWith(self, s, prefix):
    90124        """
    91125        Assert that C{s} starts with a particular C{prefix}.
     
    9771011            self._throwIntoGenerator(f, g)
    9781012        except:
    9791013            self.assertIsInstance(failure.Failure().value, IndexError)
     1014
     1015
     1016
     1017if _PY3:
     1018    FailureTestCase.test_TrappedAndReRaiseFailure.skip = "This test works only with Python 2"
     1019