def test_event_future(): queue = core.EventQueue() handler = core.EventHandler(queue) fut = handler.get_future("test") # If we ask again, we should get the same one. assert handler.get_future("test") == fut event = core.Event("test") handler.dispatch_event(event) assert fut.done() assert not fut.cancelled() assert fut.result() == event
def test_event_future_cancel(): # This is a very strange thing to do, but it's possible, so let's make # sure it gives defined behavior. queue = core.EventQueue() handler = core.EventHandler(queue) fut = handler.get_future("test") fut.cancel() assert fut.done() assert fut.cancelled() event = core.Event("test") handler.dispatch_event(event) assert fut.done() assert fut.cancelled()