How to use the aiofile.utils.LineReader function in aiofile

To help you get started, we’ve selected a few aiofile examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mosquito / aiofile / tests / test_aio.py View on Github external
async def test_line_reader(aio_file_maker, temp_file, uuid):
    afp = await aio_file_maker(temp_file, 'w+')

    writer = Writer(afp)

    lines = [uuid4().hex for _ in range(1000)]

    for line in lines:
        await writer(line)
        await writer('\n')

    read_lines = []

    async for line in LineReader(afp):
        read_lines.append(line[:-1])

    assert lines == read_lines
github mosquito / aiofile / tests / test_py35 / test_aio.py View on Github external
async def test_line_reader_one_line(aio_file_maker, temp_file):
    afp = await aio_file_maker(temp_file, 'w+')

    writer = Writer(afp)

    payload = " ".join(uuid4().hex for _ in range(1000))

    await writer(payload)

    read_lines = []

    async for line in LineReader(afp):
        read_lines.append(line)

    assert payload == read_lines[0]