Example #1
0
def test_done_then_dequeue():
    pool = CompletionOrderedAsyncWorkPool()
    pool.set_all_work_received_flag()
    result = pool.__anext__()
    cirq.testing.assert_asyncio_will_raise(result,
                                           StopAsyncIteration,
                                           match='no_more_work')
Example #2
0
def test_async_all_done_pre_flag():
    pool = CompletionOrderedAsyncWorkPool()
    done = pool.async_all_done()

    cirq.testing.assert_asyncio_still_running(done)
    pool.set_all_work_received_flag()
    cirq.testing.assert_asyncio_will_have_result(done, None)
Example #3
0
async def test_async_all_done_pre_flag():
    pool = CompletionOrderedAsyncWorkPool()
    done = pool.async_all_done()

    assert await cirq.testing.asynchronous.asyncio_pending(done)
    pool.set_all_work_received_flag()
    assert await done is None
Example #4
0
async def test_dequeue_then_done():
    pool = CompletionOrderedAsyncWorkPool()
    result = pool.__anext__()
    assert await cirq.testing.asynchronous.asyncio_pending(result)
    pool.set_all_work_received_flag()
    with pytest.raises(StopAsyncIteration, match='no_more_work'):
        await result
Example #5
0
def test_async_all_done_flag_then_finish_work():
    pool = CompletionOrderedAsyncWorkPool()
    done = pool.async_all_done()

    work = asyncio.Future()
    pool.include_work(work)
    pool.set_all_work_received_flag()

    cirq.testing.assert_asyncio_still_running(done)
    work.set_result(5)
    cirq.testing.assert_asyncio_will_have_result(done, None)
Example #6
0
async def test_async_all_done_flag_then_finish_work():
    pool = CompletionOrderedAsyncWorkPool()
    done = pool.async_all_done()

    work = asyncio.Future()
    pool.include_work(work)
    pool.set_all_work_received_flag()

    assert await cirq.testing.asynchronous.asyncio_pending(done)
    work.set_result(5)
    assert await done is None
Example #7
0
def test_async_all_done_post_flag():
    pool = CompletionOrderedAsyncWorkPool()
    pool.set_all_work_received_flag()
    cirq.testing.assert_asyncio_will_have_result(pool.async_all_done(), None)
    cirq.testing.assert_asyncio_will_have_result(pool.async_all_done(), None)
Example #8
0
async def test_async_all_done_post_flag():
    pool = CompletionOrderedAsyncWorkPool()
    pool.set_all_work_received_flag()
    assert await pool.async_all_done() is None
    assert await pool.async_all_done() is None
Example #9
0
async def test_done_then_dequeue():
    pool = CompletionOrderedAsyncWorkPool()
    pool.set_all_work_received_flag()
    result = pool.__anext__()
    with pytest.raises(StopAsyncIteration, match='no_more_work'):
        await result