'Fail the test unless calling the function :py:data:`f` with the given
:py:data:`args` and :py:data:`kwargs` raises :py:data:`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: The raised exception instance, if it is of the given type.
:raise self.failureException: Raised if the function call does
not raise an exception or if it raises an exception of a
different type.'

def failUnlessRaises(self, exception, f, *args, **kwargs):

    try:
        result = f(*args, **kwargs)
    except exception:
        inst = sys.exc_info()[1]
        return inst
    except:
        raise self.failureException(('%s    raised    instead    of    %s' % (sys.exc_info()[0], exception.__name__)))
    else:
        raise self.failureException(('%s    not    raised    (%r    returned)' % (exception.__name__, result)))
