示例#1
0
def test_trigger():
    future = Future()
    callback = mock.Mock(spec=())
    future.add_done_callback(callback)
    assert callback.call_count == 0
    future.set_result('12345')
    callback.assert_called_once_with(future)
示例#2
0
def test_add_done_callback_pending_batch():
    future = Future()
    callback = mock.Mock()
    future.add_done_callback(callback)
    assert len(future._callbacks) == 1
    assert callback in future._callbacks
    assert callback.call_count == 0
示例#3
0
def test_add_done_callback_completed_batch():
    future = Future()
    future.set_result('12345')
    callback = mock.Mock(spec=())
    future.add_done_callback(callback)
    callback.assert_called_once_with(future)