'Assert that the given Deferred current result is a Failure with the
given exception.
@return: The exception instance in the Deferred.'

def assertImmediateFailure(self, deferred, exception):

    failures = []
    deferred.addErrback(failures.append)
    self.assertEqual(len(failures), 1)
    self.assertTrue(failures[0].check(exception))
    return failures[0].value
