def test_cancel_invokes_callbacks(self): called = False def cb(fut): nonlocal called called = True f = Future() f.add_done_callback(cb) f.cancel() assert called
def test_cancel_schedules_callbacks(self): executor = DummyExecutor() f = Future(executor=executor) f.add_done_callback(lambda f: None) f.cancel() self.assertTrue(executor.done_callbacks)
def test_cancelled(self): f = Future() f.cancel() self.assertTrue(f.cancelled())