skillfed

pytest-aiohttp

Pytest plugin for aiohttp support

pytest-aiohttp v1.1.1 6.0M downloads/30d#1,979 on PyPI143
Permissive license Apache 2.0 Active released

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

uv

uv add pytest-aiohttp

poetry

poetry add pytest-aiohttp

Installing 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

Development Status :: 4 - BetaFramework :: AsyncIOFramework :: PytestFramework :: aiohttpIntended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Software Development :: TestingTyping :: Typed

Tags

pytest aiohttp testingasync http server testingaiohttp fixtures pytesttest aiohttp client serverpytest asyncio aiohttp
async-testingaiohttppytest-plugin

More Testing packages