'After an exception is raised by a callback which was added to a
L{Deferred} by a callback on that L{Deferred}, the L{Deferred} should
call the first errback with a L{Failure} wrapping that exception.'

def test_reentrantRunCallbacksWithFailure(self):

    exceptionMessage = 'callback    raised    exception'
    deferred = defer.Deferred()
    def callback2(result):
        raise Exception(exceptionMessage)
    def callback1(result):
        deferred.addCallback(callback2)
    deferred.addCallback(callback1)
    deferred.callback(None)
    exception = self.assertImmediateFailure(deferred, Exception)
    self.assertEqual(exception.args, (exceptionMessage,))
