pytest-asyncio

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

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

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
90 /100 Excellent
Development Activity 92
Maintenance 84
Community 84
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
80 /100 Excellent
Architecture 78
Code Quality 88
Innovation 70
Learning Curve 82

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 49 apps in this directory

Rust
79%
MIT

mnemo

AI Agents · AI Development · AI Memory

237

A local-first AI memory sidecar that extracts entities, builds a persistent knowledge graph, and injects ranked context into any LLM pipeline — no cloud required.

View details
27
Repo Health
78
Technical
76
Dependency
Built with
Rust 79%
Python 16%
Updated 4 months ago
Python
66%
Other

Morphik

AI Development · Databases · Search

3,717

Morphik is an AI-native ingestion and retrieval engine that lets developers store, search, and reason over visually rich documents — scanned PDFs, manuals, slides, and video — without duct-taping together OCR, an embedding model, and a vector database.

View details
64
Repo Health
71
Technical
67
Dependency
Built with
Python 66%
TypeScript 23%
Updated 1 weeks ago
JavaScript
40%
MIT

NoteDiscovery

Knowledge Management · Note Taking · Productivity

2,846

A self-hosted markdown knowledge base with MCP-powered AI integration, graph views, LaTeX math, and built-in drawing — your notes stay on your server, forever.

View details
81
Repo Health
59
Technical
74
Dependency
Built with
JavaScript 40%
Python 32%
HTML 24%
Updated 6 days ago
TypeScript
60%
MIT

oh-my-claudecode

AI Agents

40,215

Multi-agent orchestration for Claude Code with zero learning curve — install as a plugin or npm CLI and coordinate parallel Claude Code agents through pre-built workflows instead of managing them by hand.

View details
85
Repo Health
70
Technical
73
Dependency
Built with
TypeScript 60%
JavaScript 39%
Updated 5 days ago
Python
100%
Other

OpenBB

Analytics · Databases · Invoicing Finance

74,601

The AI Workspace for Finance: Connect Data, Run AI Agents, Build Analytics

View details
80
Repo Health
80
Technical
65
Dependency
Built with
Python 100%
Updated 1 weeks ago
TypeScript
92%
Other

OpenHands

AI Code Assistants · AI Development

91,695

The self-hosted developer control center for running AI coding agents — locally, in Docker, on VMs, or across cloud backends — with automation workflows for GitHub, Slack, and more.

View details
91
Repo Health
82
Technical
67
Dependency
Built with
TypeScript 92%
Updated 6 days ago
Python
74%
Apache 2.0

OpenKB

Knowledge Management

4,804

An open-source CLI that compiles raw documents into a structured, interlinked wiki-style knowledge base using LLMs — powered by vectorless, reasoning-based retrieval (PageIndex) instead of a vector database.

View details
48
Repo Health
72
Technical
77
Dependency
Built with
Python 74%
TypeScript 23%
Updated 3 months ago
Python
39%
Apache 2.0

OpenSandbox

Developer Tools · Security

16,116

Secure, fast, and extensible sandbox runtime for AI agents with multi-language SDKs and Docker/Kubernetes runtimes.

View details
85
Repo Health
81
Technical
70
Dependency
Built with
Python 39%
Go 36%
Updated 5 days ago
Python
73%
AGPL 3.0

OpenViking

AI Development · AI Memory · Databases

40,705

An open-source context database that gives AI agents a unified filesystem for memory, resources, and skills with hierarchical tiered retrieval.

View details
85
Repo Health
75
Technical
64
Dependency
Built with
Python 73%
TypeScript 12%
Rust 11%
Updated 5 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