def test_failureConstructionFindsOriginalFailure(self):
        """
        When a Failure is constructed in the context of an exception
        handler that is handling an exception raised by
        throwExceptionIntoGenerator, the new Failure should be chained to that
        original Failure.
        """
        f = getDivisionFailure()
        f.cleanFailure()
        original_failure_str = f.getTraceback()

        newFailures = []

        def generator():
            try:
                yield
            except:
                newFailures.append(failure.Failure())
            else:
                self.fail("No exception sent to generator")
        g = generator()
        next(g)
        self._throwIntoGenerator(f, g)

        self.assertEqual(len(newFailures), 1)

        # The original failure should not be changed.
        self.assertEqual(original_failure_str, f.getTraceback())

        # The new failure should be different and contain stack info for
        # our generator.
        self.assertNotEqual(newFailures[0].getTraceback(), f.getTraceback())
        self.assertIn("generator", newFailures[0].getTraceback())
        self.assertNotIn("generator", f.getTraceback())

        When a Failure is constructed in the context of an exception
        handler that is handling an exception raised by
        throwExceptionIntoGenerator, the new Failure should be chained to that
        original Failure.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_failure.py