pytest-trio
Pytest plugin for trio
What it is and what it does
pytest-trio is a pytest plugin that bridges the gap between pytest's synchronous test runner and Trio's async I/O library. It lets you write test functions as async coroutines and run them directly under pytest, handling the event loop setup and teardown automatically. The plugin depends on trio, outcome, and pytest.
The package is designed for projects already using Trio for concurrency and async I/O. Instead of writing wrapper functions or manually managing the event loop in tests, you mark async test functions with @pytest.mark.trio and pytest-trio runs them in a Trio context. It integrates with pytest's fixture system and supports Hypothesis for property-based testing of async code.
Use it for:
- Write async unit tests for Trio-based libraries without manual event loop management.
- Test concurrent I/O operations and async functions in isolation using pytest fixtures.
- Run property-based tests on async code via Hypothesis integration.
- Validate error handling and cancellation behavior in async Trio applications.
- Integrate async testing into existing pytest test suites without restructuring.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A pytest plugin that enables testing of async code written with Trio, allowing you to write and run async test functions directly within pytest.
Yes, if you are testing Trio-based code. The plugin is stable, well-integrated with pytest, and carries no security vulnerabilities. The aging maintenance (last release November 2022) is a minor concern but not a blocker—the project remains unarchived and the core functionality is mature. Install it as a dev dependency for any project using Trio.
Install
pytest-trio on PyPI
pip
pip install pytest-triouv
uv add pytest-triopoetry
poetry add pytest-trioInstalling pytest-trio
Before you install
Low install friction with a pure-Python wheel. Maintenance is aging—last release was in November 2022 and no commits since October 2025—but the repository remains active and unarchived, suggesting the project is stable rather than abandoned.
License in practice
Licensed under MIT or Apache 2.0 at your choice, both permissive licenses with no restrictions on commercial or private use.
Quickstart
pip install pytest-trio
import trio
import pytest
@pytest.mark.trio
async def test_example():
await trio.sleep(0)
Requires Python 3.7 or later; Trio must be installed as a runtime dependency.
Verify before relying
- Whether the aging maintenance status (last release Nov 2022) affects compatibility with recent Trio or pytest versions.
- Current test coverage and whether the plugin handles all Trio cancellation and timeout patterns.
Package facts
| License | MIT OR Apache-2.0 (permissive) |
| Python support | supports the current Python release (>=3.7) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — trio, outcome, pytest |
| Maintenance | aging — 1,382 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 394,538/month — #6,990 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pytest_trio-0.8.0-py3-none-any.whl
Keywords: async, pytest, testing, trio
Tags
More Testing packages
Pluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
virtualenvvirtualenv creates isolated Python environments…
permissive · top 100 on PyPI
coverageCoverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
pytest-asynciopytest-asyncio is a pytest plugin that enables…
permissive · top 1,000 on PyPI
pytest-json-ctrfA pytest plugin that generates test reports in…
permissive · top 1,000 on PyPI
pytest-aioA pytest plugin that automatically runs async…
permissive · top 15,000 on PyPI
trioTrio is an async I/O library that lets you…
permissive · top 1,000 on PyPI
sniffioDetects which async library (asyncio, Trio,…
permissive · top 100 on PyPI
async_generatorProvides async generators and async context…
permissive · top 5,000 on PyPI
pytest-run-parallelA pytest plugin that runs test functions…
permissive · top 15,000 on PyPI
outcomeCaptures the outcome of Python function…
permissive · top 1,000 on PyPI
flake8-asyncA flake8 plugin that detects async-related…
permissive · top 15,000 on PyPI
unasyncTransforms asynchronous Python code into…
permissive · top 15,000 on PyPI
pytest-twistedA pytest plugin that enables testing of…
permissive · top 15,000 on PyPI
pytest-djangopytest-django integrates Django with pytest,…
permissive · top 1,000 on PyPI