pytest-aiohttp
Pytest plugin for aiohttp support
What it is and what it does
pytest-aiohttp is a pytest plugin that bridges pytest and aiohttp for testing async HTTP applications. It provides fixtures (like aiohttp_client) that simplify creating test servers and clients within async test functions, with automatic cleanup of resources. The plugin integrates with pytest-asyncio to run async tests, requiring you to configure pytest with asyncio_mode set to 'auto' or 'strict'.
You write tests in pytest-asyncio style, instantiate an aiohttp application, pass it to the aiohttp_client fixture to get a test client, then make requests and assert on responses. The plugin handles the lifecycle—starting the server, managing the client connection, and tearing down resources—so you focus on test logic rather than setup and teardown boilerplate.
Use it for:
- Test aiohttp web handlers by creating an in-process test server and client within async test functions
- Verify HTTP request/response behavior (status codes, headers, body content) in aiohttp applications
- Test middleware, error handlers, and routing logic in aiohttp web apps without external network calls
- Validate async request/response cycles in integration tests that need both server and client running
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Pytest plugin that provides fixtures for testing aiohttp applications with async test support, handling server and client creation plus automatic resource cleanup.
Yes. The plugin is actively maintained, has no known vulnerabilities, supports current Python versions (3.10–3.14), and solves a real problem—testing aiohttp apps requires boilerplate that this plugin eliminates. Install if you're writing tests for aiohttp applications and want fixtures that handle server/client lifecycle automatically.
Install
pytest-aiohttp on PyPI
pip
pip install pytest-aiohttpuv
uv add pytest-aiohttppoetry
poetry add pytest-aiohttpInstalling pytest-aiohttp
Before you install
Low friction install with three well-maintained runtime dependencies (pytest, aiohttp, pytest-asyncio). Repository is active with recent commits and no archived status.
License in practice
Apache 2.0 permissive license allows use in most commercial and open-source projects without significant restrictions.
Quickstart
pip install pytest-aiohttp
# In pytest.ini or pyproject.toml:
# [tool.pytest.ini_options]
# asyncio_mode = "auto"
from aiohttp import web
async def test_hello(aiohttp_client):
app = web.Application()
app.router.add_route("GET", "/", lambda r: web.Response(text="Hello"))
client = await aiohttp_client(app)
resp = await client.get("/")
assert resp.status == 200
Requires pytest.ini or pyproject.toml configuration with asyncio_mode set to 'auto' or 'strict' for pytest-asyncio.
Verify before relying
- Whether the plugin works with pytest-asyncio modes other than 'auto' and 'strict' without configuration changes
- Performance characteristics when testing large numbers of concurrent aiohttp client/server pairs
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 — pytest, aiohttp, pytest-asyncio |
| Maintenance | actively maintained — 68 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 6,033,878/month — #1,979 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pytest_aiohttp-1.1.1-py3-none-any.whl
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-homeassistant-custom-componentProvides pytest fixtures and testing utilities…
permissive · top 5,000 on PyPI
aresponsesMocks external HTTP/HTTPS services for…
permissive · top 15,000 on PyPI
aioresponsesMocks HTTP requests made by aiohttp's…
permissive · top 5,000 on PyPI
pytest-qtpytest-qt is a pytest plugin that provides…
permissive · top 5,000 on PyPI
aiointerceptIntercepts aiohttp client requests by routing…
permissive · top 15,000 on PyPI
pytest-seleniumpytest-selenium is a pytest plugin that…
copyleft · top 15,000 on PyPI
pytest-aioA pytest plugin that automatically runs async…
permissive · top 15,000 on PyPI
molotovMolotov is a load testing tool that uses…
permissive · top 15,000 on PyPI
pytest-asyncio-concurrentA pytest plugin that executes async test…
permissive · top 15,000 on PyPI