def __exit__(self, exceptionType, exceptionValue, traceback):
        """
        Check exit exception against expected exception.
        """
        # No exception raised.
        if exceptionType is None:
            self._testCase.fail(
                "{0} not raised ({1} returned)".format(
                    self._expectedName, self._returnValue)
                )

        if not isinstance(exceptionValue, exceptionType):
            # Support some Python 2.6 ridiculousness.  Exceptions raised using
            # the C API appear here as the arguments you might pass to the
            # exception class to create an exception instance.  So... do that
            # to turn them into the instances.
            if isinstance(exceptionValue, tuple):
                exceptionValue = exceptionType(*exceptionValue)
            else:
                exceptionValue = exceptionType(exceptionValue)

        # Store exception so that it can be access from context.
        self.exception = exceptionValue

        # Wrong exception raised.
        if not issubclass(exceptionType, self._expected):
            reason = failure.Failure(exceptionValue, exceptionType, traceback)
            self._testCase.fail(
                "{0} raised instead of {1}:\n {2}".format(
                    fullyQualifiedName(exceptionType),
                    self._expectedName, reason.getTraceback()),
                )

        # All good.
        return True

        Check exit exception against expected exception.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/trial/_synctest.py