Exemplo n.º 1
0
async def test_internal_queue_put_delay():
    queue = InternalQueue(maxsize=1)
    queue.put_nowait(False)
    task = asyncio.create_task(queue.put(True))

    await asyncio.sleep(0.001)
    assert queue.get_nowait() is False
    await asyncio.sleep(0.001)
    assert task.done()
    assert queue.get_nowait() is True
Exemplo n.º 2
0
def test_queue_mock_context_sync():
    queue = InternalQueue()

    with QueueMockContext(queue) as m:
        queue.put_nowait(1)
        queue.put_nowait(2)
        queue.get_nowait()

    assert m.put_items == [1, 2]
    assert m.got_items == [1]
Exemplo n.º 3
0
async def test_internal_queue_get_nowait_empty():
    queue = InternalQueue()
    with pytest.raises(QueueEmpty):
        queue.get_nowait()
Exemplo n.º 4
0
async def test_internal_queue_get_nowait():
    queue = InternalQueue()
    await queue.put(True)
    assert queue.get_nowait() is True