pytest-asyncio
Pytest support for asyncio
Decision gist · record as of 2026-08-14
Yes. pytest-asyncio is the standard pytest plugin for async testing, actively maintained, permissively licensed, and has no known vulnerabilities. Install it if you write tests for any asyncio-based code. The only condition is that your Python version is 3.10 or later.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.10 or later.
- Low friction installation with a pure-Python wheel.
- The package is actively maintained with a recent release (80 days ago) and has been in development since 2015.
License · maintenance · safety
Apache-2.0 (permissive) — Licensed under Apache License 2.0 (permissive), which allows use in commercial and proprietary projects with minimal restrictions.
last release 2026-05-26 (80 days) · last repo commit 2026-08-12 · 1,656 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 275,917,521 downloads/mo, #146 on PyPI
Alternatives
Verify before relying
pip install pytest-asyncio
# In your test file:
import pytest
@pytest.mark.asyncio
async def test_async_code():
result = await some_async_function()
assert result == expected- Whether event loop management and fixture setup for async tests is documented sufficiently for new users.
- Support for async test classes or whether unittest.IsolatedAsyncioTestCase is the recommended alternative.
What it is and what it does
pytest-asyncio bridges pytest and Python's asyncio library, letting you write test functions as async coroutines and await asynchronous code directly within them. Instead of wrapping async calls in synchronous test harnesses, you mark a test with @pytest.mark.asyncio and write it as an async function, making async test code read naturally and reducing boilerplate.
The plugin handles event loop setup and teardown automatically. It depends on pytest, typing-extensions, and backports-asyncio-runner to support older Python versions. The package is production-stable, actively maintained, and widely used—it ranks in the top 1000 PyPI packages by download volume.
Use it for
- Testing async web frameworks (FastAPI, aiohttp, Starlette) by awaiting request handlers and assertions.
- Unit testing async database clients or ORMs that use asyncio for non-blocking I/O.
- Integration testing microservices or async message queues without blocking the test runner.
- Testing async generator functions and context managers in your own asyncio-based libraries.
- Running concurrent test scenarios that require multiple coroutines to execute in the same event loop.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
pytest-asyncio is the standard pytest plugin for async testing, actively maintained, permissively licensed, and has no known vulnerabilities. Install it if you write tests for any asyncio-based code. The only condition is that your Python version is 3.10 or later.
Install
pytest-asyncio on PyPI
Before you install
Low friction installation with a pure-Python wheel. The package is actively maintained with a recent release (80 days ago) and has been in development since 2015. Runtime dependencies are minimal: pytest, typing-extensions, and backports-asyncio-runner.
Requires Python 3.10 or later.
License in practice
Licensed under Apache License 2.0 (permissive), which allows use in commercial and proprietary projects with minimal restrictions.
Quickstart
pip install pytest-asyncio
# In your test file:
import pytest
@pytest.mark.asyncio
async def test_async_code():
result = await some_async_function()
assert result == expected
Verify before relying
- Whether event loop management and fixture setup for async tests is documented sufficiently for new users.
- Support for async test classes or whether unittest.IsolatedAsyncioTestCase is the recommended alternative.
Package facts
| License | Apache-2.0 permissive |
| Python support | Supports the current Python release >=3.10 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 3 packagesbackports-asyncio-runnerpytesttyping-extensions |
| Maintenance | Actively maintained 80 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 275,917,521 / month, #146 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableFramework :: AsyncIOFramework :: PytestIntended Audience :: DevelopersProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Software Development :: TestingTyping :: Typed |
Evidence: pytest_asyncio-1.4.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “pytest async test support”
- pytest-asynciopytest-asyncio is a pytest plugin that enables writing and running…
- pytest-aiohttpPytest plugin that provides fixtures for testing aiohttp applications…
- pytest-trioA pytest plugin that enables testing of async code written with Trio,…
Give your agent the search over MCP, or paste the wish link into any chat.
More Testing packages
Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.
Install it if you're building an extensible application or framework.
pytest is a testing framework that lets you write test functions using plain assert statements and automatically discovers and runs them, with detailed failure reporting.
virtualenv creates isolated Python environments where packages can be installed independently without affecting the system Python or other projects.
Coverage.py measures which lines of Python code are executed during test runs, reporting coverage percentages and identifying untested code paths.
Install it if you want to measure test completeness or enforce coverage thresholds in your project.
A pytest plugin that generates test reports in Common Test Report Format (CTRF) as JSON, compatible with pytest-xdist and pytest-playwright for distributed and browser-based testing.
Install it if you need CTRF-formatted test output for CI/CD integration or cross-tool reporting.
A pytest plugin that measures code coverage during test runs, automatically combining coverage data and supporting distributed testing with pytest-xdist.
Install it if you want coverage reports as part of your normal test workflow.
See also aiounittest · asyncmock · asynctest · pytest-aiohttp · pytest-asyncio-concurrent · pytest-twisted · looptime · pytest-playwright-asyncio · pytest-tornasync