API Reference

pytest-asyncio

A pytest plugin that runs async test functions and fixtures using an asyncio event loop.

Official Documentation ↗
CompatibilityThis documentation covers version v0.23. Check the official docs for the latest API surface.

Installation

pippip install pytest-asyncio

Methods

pytest-asyncio supplies an event loop fixture and marks so async functions are awaited by pytest.

Key Features

  • Async test functions and fixtures
  • asyncio_mode strict or auto
  • Event loop scoping control

Usage Notes

Pin a version and check the official docs for the API surface you depend on before upgrading.

API reference evidence

Fetched from official sources on 2026-11-08T17:31:00+08:00 via WebFetch https://pytest-asyncio.readthedocs.io/en/latest/concepts.html.

FAQ

Do I still need the mark in auto mode?
No. With asyncio_mode = auto, async tests are discovered automatically and the explicit mark becomes optional.
How do I share an event loop?
Use loop_scope on fixtures and marks so fixtures and tests agree on a loop, avoiding cross-loop errors.
Why does my async fixture fail?
An async fixture must be declared with pytest_asyncio.fixture rather than the plain pytest fixture decorator.