'Verify that a L{defer.Deferred} calls its specified canceller when
it is cancelled, and that further call/errbacks raise
L{defer.AlreadyCalledError}.'

def test_simpleCanceller(self):

    def cancel(d):
        self.cancellerCallCount += 1
    d = defer.Deferred(canceller=cancel)
    d.addCallbacks(self._callback, self._errback)
    d.cancel()
    self.assertEqual(self.cancellerCallCount, 1)
    self.assertEqual(self.errbackResults.type, defer.CancelledError)
    self.assertRaises(defer.AlreadyCalledError, d.callback, None)
    self.assertRaises(defer.AlreadyCalledError, d.errback, Exception())
