pytest-aiofiles

pytest-aiofiles provides pytest fixtures for writing aiofiles tests using pyfakefs, instead of real file IO.

Features

  • fake filesystem fixture attached to aiofiles
  • automatic aiofiles monkey-patching

Library Installation

$ pip install pytest-aiofiles

Getting Started

import aiofiles
import pytest

@pytest.mark.asyncio
async def test_stuff(afs):
    filename = 'test'

    async with aiofiles.open(test, 'w') as f:
        await f.seek(0)

    assert afs.Exists(filename)

Contents

Indices and tables