'An errback added before a timeout is added errbacks with a
L{defer.CancelledError} when the timeout fires.  If the
errback returns the L{defer.CancelledError}, it is translated
to a L{defer.TimeoutError} by the timeout implementation.'

def test_errbackAddedBeforeTimeout(self):

    clock = Clock()
    d = defer.Deferred()
    dErrbacked = [None]
    def errback(f):
        dErrbacked[0] = f
        return f
    d.addErrback(errback)
    d.addTimeout(10, clock)
    clock.advance(15)
    self.assertIsInstance(dErrbacked[0], failure.Failure)
    self.assertIsInstance(dErrbacked[0].value, defer.CancelledError)
    self.failureResultOf(d, defer.TimeoutError)
