skillfed

pytest-trio

Pytest plugin for trio

pytest-trio v0.8.0 394.5K downloads/30d#6,990 on PyPI61
Permissive license MIT OR Apache-2.0 AGING released

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-trio

uv

uv add pytest-trio

poetry

poetry add pytest-trio

Installing 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

Framework :: HypothesisFramework :: PytestFramework :: TrioLicense :: OSI Approved :: Apache Software LicenseLicense :: OSI Approved :: MIT LicenseOperating System :: MacOS :: MacOS XOperating System :: Microsoft :: WindowsOperating System :: POSIX :: LinuxProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: TestingTopic :: System :: Networking

Tags

pytest async testingtrio test pluginasync pytest fixturesconcurrent testing frameworktrio async testingpytest trio integrationasync io testing
async-testingtrio-integration

More Testing packages