Exemple #1
0
    async def test_get_nowait_throw_first_in_buffer(self):
        flow_control = FlowControlEvent(initially_suspended=False)
        queue = ThrowableQueue(flow_control=flow_control)

        await queue.put(1)
        await queue.put(2)
        assert queue.get_nowait() == 1
        assert queue.get_nowait() == 2
        await queue.put(3)
        await queue.put(4)
        await queue.throw(KeyError('foo'))
        with pytest.raises(KeyError):
            queue.get_nowait()
        assert queue.get_nowait() == 3
        assert queue.get_nowait() == 4
        await queue.throw(ValueError('bar'))
        with pytest.raises(ValueError):
            queue.get_nowait()
Exemple #2
0
    def test_get_nowait_empty(self):
        flow_control = FlowControlEvent(initially_suspended=False)
        queue = ThrowableQueue(flow_control=flow_control)

        with pytest.raises(asyncio.QueueEmpty):
            queue.get_nowait()