def test_failureResultOfWithWrongFailureOneExpectedFailure(self):
        """
        L{SynchronousTestCase.failureResultOf} raises
        L{SynchronousTestCase.failureException} when called with a L{Deferred}
        with a failure type that was not expected, and the
        L{SynchronousTestCase.failureException} message contains the original
        failure traceback as well as the expected failure type
        """
        try:
            self.failureResultOf(fail(self.failure), KeyError)
        except self.failureException as e:
            self.assertIn(self.failure.getTraceback(), str(e))
            self.assertIn(
                "Failure of type ({0}.{1}) expected on".format(
                    KeyError.__module__, KeyError.__name__),
                str(e))

        L{SynchronousTestCase.failureResultOf} raises
        L{SynchronousTestCase.failureException} when called with a L{Deferred}
        with a failure type that was not expected, and the
        L{SynchronousTestCase.failureException} message contains the original
        failure traceback as well as the expected failure type
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/trial/test/test_assertions.py