'Callbacks should be invoked in the order they were scheduled.'

def test_threadsAreRunInScheduledOrder(self):

    order = []
    def check(_):
        self.assertEqual(order, [1, 2, 3])
    self.deferred.addCallback(check)
    self.schedule(order.append, 1)
    self.schedule(order.append, 2)
    self.schedule(order.append, 3)
    self.schedule(reactor.callFromThread, self.deferred.callback, None)
    return self.deferred
