pytest-asyncio

The pytest plugin that lets you write and run async/await test functions and fixtures directly.

Tool
PyPI
v1.4.0
1,656stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
91/100Excellent
Development Activity96
Maintenance84
Community84
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
80/100Excellent
Architecture78
Code Quality88
Innovation70
Learning Curve82

pytest-asyncio is a pytest plugin that makes it possible to write coroutine test functions and have pytest execute them correctly — no manual event-loop boilerplate required. Marking a test @pytest.mark.asyncio (or enabling the asyncio_mode = auto config option) lets you await code inside the test body just like you would in application code, and pytest-asyncio takes care of driving the event loop and running the coroutine to completion.

Maintained under the pytest-dev organization alongside pytest itself, it’s the de facto standard way to test asyncio-based Python code with pytest, supporting async fixtures with configurable scope (function, module, session), parametrized event loops, and custom loop factories. It explicitly does not support unittest.TestCase subclasses, pointing users instead to unittest.IsolatedAsyncioTestCase or an async-aware test framework for that case.

What You Get

  • pytest.mark.asyncio to mark individual coroutine functions as pytest test items
  • An asyncio_mode = auto configuration option that treats every async def test/fixture as async automatically, without per-test markers
  • Async fixtures with configurable scope (function, class, module, session) via @pytest_asyncio.fixture
  • Support for custom event loop factories and parametrized event loop configurations across a test session
  • Integration with pytest’s existing fixture, parametrization, and collection machinery so async tests behave like any other pytest test

Common Use Cases

  • Unit and integration testing of asyncio-based application code (async web frameworks, async DB clients, async task queues)
  • Testing async context managers and async generators used as pytest fixtures with proper setup/teardown scoping
  • Running the same async test logic against multiple event loop configurations via parametrization
  • Migrating a codebase from manual asyncio.run()-wrapped tests to native async def test functions

Under The Hood

Architecture — The entire plugin lives in a single, focused module, pytest_asyncio/plugin.py (1,140 lines), which hooks into pytest’s collection and fixture machinery to detect async def test functions and fixtures, wrap them in an event loop runner, and manage loop lifecycle/scope so fixtures and tests sharing a scope share the same running loop. __init__.py exposes the small public surface (fixture, marker registration) that users actually import.

Tech Stack — Pure Python with pytest as its only required dependency (plus typing-extensions on older Pythons), designed to work with any asyncio-based code without also depending on a specific async framework (no forced dependency on Tornado, Trio, etc.) — it strictly targets Python’s built-in asyncio.

Code Quality — Exceptionally thorough test suite: 37+ test modules covering markers, fixture scopes (tests/modes/), event loop factories, subprocess handling, doctest support, Hypothesis-based property tests, and even task-cleanup edge cases — unusually deep coverage for a plugin of this size, backed by Codecov reporting and CI across supported Python versions. py.typed is shipped, signaling committed type-hint support for consumers.

API Design — The @pytest.mark.asyncio / asyncio_mode=auto split is a deliberate ergonomics choice: teams can opt into per-test explicitness or blanket-enable async support project-wide once they’ve standardized on it. The README is upfront about a real limitation (no support for unittest.TestCase subclasses) rather than leaving users to discover it via a confusing failure, which meaningfully shortens the debugging loop for newcomers.

Used by 48 apps in this directory

Python
66%
Apache 2.0

Agent Control

AI Agents

295

An open-source runtime control plane for AI agents — define safety guardrails once, apply them across agents built on LangChain, CrewAI, Google ADK, or AWS Strands, and update controls without redeploying code.

View details
79
Repo Health
71
Technical
70
Dependency
Built with
Python66%
TypeScript33%
Updated yesterday
Python
100%
Apache 2.0

Agno

Devops · AI Development · Automation

41,774

Build, run, and manage agent platforms with a full production stack — SDK, runtime, and control plane included.

View details
93
Repo Health
87
Technical
67
Dependency
Built with
Python100%
Updated today
Python
49%
Other

Airbyte

Developer Tools · Data Engineering

21,916

Open-source ELT platform with 600+ connectors for moving data from any source to warehouses, lakes, and AI agents.

View details
95
Repo Health
80
Technical
67
Dependency
Built with
Python49%
Kotlin42%
Updated today
Python
90%
Apache 2.0

Apache Airflow

Data Engineering

46,530

Define, schedule, and monitor complex data workflows as Python code — with a powerful UI, 80+ provider integrations, and battle-tested scalability across thousands of production deployments.

View details
96
Repo Health
89
Technical
66
Dependency
Built with
Python90%
Updated today
Python
59%
Apache 2.0

argilla

AI Development · Data Engineering

5,081

Collaborate on high-quality AI training data with a self-hosted annotation platform built for LLMs, NLP, and multimodal models.

View details
65
Repo Health
81
Technical
63
Dependency
Built with
Python59%
Jupyter Notebook21%
Updated 2 days ago
Python
68%
Other

AutoGPT

Automation · Productivity · AI Assistants

186,687

Build, deploy, and run autonomous AI agents that automate complex multi-step workflows using a visual block-based graph editor.

View details
93
Repo Health
78
Technical
67
Dependency
Built with
Python68%
TypeScript31%
Updated today
TypeScript
48%
AGPL 3.0

Banana Slides

AI Design Tools · Productivity

15,476

AI-native PPT generator with Vibe editing, multi-LLM support, and fully editable PPTX export

View details
83
Repo Health
82
Technical
71
Dependency
Built with
TypeScript48%
Python47%
Updated 3 days ago
Python
100%
GPL 3.0

ComfyUI

AI Design Tools · AI Development

128,363

The most powerful node-based AI workflow engine for creating images, video, 3D models, and audio with full control over every generation step.

View details
92
Repo Health
81
Technical
75
Dependency
Built with
Python100%
Updated today
Python
51%
MIT

Docs

File Storage · CMS

16,733

Open-source collaborative knowledge platform with real-time editing, AI writing tools, and full self-hosting control — built by the French and German governments.

View details
87
Repo Health
81
Technical
72
Dependency
Built with
Python51%
TypeScript42%
Updated 2 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search