def assertRaises(self, exception, f=None, *args, **kwargs):
        """
        Fail the test unless calling the function C{f} with the given
        C{args} and C{kwargs} raises C{exception}. The failure will report
        the traceback and call stack of the unexpected exception.

        @param exception: exception type that is to be expected
        @param f: the function to call

        @return: If C{f} is L{None}, a context manager which will make an
            assertion about the exception raised from the suite it manages.  If
            C{f} is not L{None}, the exception raised by C{f}.

        @raise self.failureException: Raised if the function call does
            not raise an exception or if it raises an exception of a
            different type.
        """
        context = _AssertRaisesContext(self, exception)
        if f is None:
            return context

        return context._handle(lambda: f(*args, **kwargs))

        Fail the test unless calling the function C{f} with the given
        C{args} and C{kwargs} raises C{exception}. The failure will report
        the traceback and call stack of the unexpected exception.

        @param exception: exception type that is to be expected
        @param f: the function to call

        @return: If C{f} is L{None}, a context manager which will make an
            assertion about the exception raised from the suite it manages.  If
            C{f} is not L{None}, the exception raised by C{f}.

        @raise self.failureException: Raised if the function call does
            not raise an exception or if it raises an exception of a
            different type.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/trial/_synctest.py