def METHOD_NAME(self):
    state = []
    def create_cb(d):
        def cb(*args):
            state.append(args)
            return d
        return cb
    d1 = defer.Deferred()
    d2 = defer.Deferred()
    self.subpt.subscribe(create_cb(d1))
    self.subpt.subscribe(create_cb(d2))
    self.assertEqual(state, [])
    self.subpt.deliver(1, 2)
    self.assertEqual(state, [(1, 2), (1, 2)])
    d = self.subpt.waitForDeliveriesToFinish()
    self.assertFalse(d.called)
    d1.callback(None)
    self.assertFalse(d.called)
    d2.callback(None)
    self.assertTrue(d.called)
    # when there are no waiting deliveries, should call the callback immediately
    d = self.subpt.waitForDeliveriesToFinish()
    self.assertTrue(d.called)