'The L{Deferred} returned by L{task.deferLater} can be
cancelled to prevent the call from actually being performed.'

def test_cancel(self):

    called = []
    clock = task.Clock()
    d = task.deferLater(clock, 1, called.append, None)
    d.cancel()
    def cbCancelled(ignored):
        self.assertEqual([], clock.getDelayedCalls())
        self.assertFalse(called)
    self.assertFailure(d, defer.CancelledError)
    d.addCallback(cbCancelled)
    return d
