'The continue callback of a L{Deferred} waiting for another L{Deferred}
is not necessarily the first one. This is somewhat a whitebox test
checking that we search for that callback among the whole list of
callbacks.'

def test_continueCallbackNotFirst(self):

    results = []
    failures = []
    a = defer.Deferred()
    def cb(result):
        results.append(('cb', result))
        d = defer.Deferred()
        def firstCallback(ignored):
            results.append(('firstCallback', ignored))
            return defer.gatherResults([a])
        def secondCallback(result):
            results.append(('secondCallback', result))
        d.addCallback(firstCallback)
        d.addCallback(secondCallback)
        d.addErrback(failures.append)
        d.callback(None)
        return d
    outer = defer.succeed('outer')
    outer.addCallback(cb)
    outer.addErrback(failures.append)
    self.assertEqual([('cb', 'outer'), ('firstCallback', None)], results)
    a.callback('withers')
    self.assertEqual([], failures)
    self.assertEqual(results, [('cb', 'outer'), ('firstCallback', None), ('secondCallback', ['withers'])])
