aioresponses
Mock out requests made by ClientSession from aiohttp package
What it is and what it does
aioresponses is a testing helper that intercepts and mocks HTTP requests made by aiohttp's ClientSession, letting you test asynchronous code without hitting real servers. It works as a decorator or context manager and lets you specify mock responses by URL, including status codes, JSON payloads, headers, and exceptions. You can also use regex patterns to match URLs, repeat responses for retry testing, simulate redirects, or pass through to real servers selectively.
The package fills a gap in the async testing ecosystem—while synchronous HTTP libraries have many mocking options, aioresponses makes it straightforward to test async code that uses aiohttp. It depends on aiohttp and packaging, both common in Python projects. The library is actively maintained and has been stable since its early releases.
Use it for:
- Test async functions that call external APIs without making real network requests
- Verify retry logic by mocking the same URL to return different status codes in sequence
- Mock JSON API responses to test data parsing in async code
- Simulate HTTP errors and exceptions to test error handling in async workflows
- Test redirect handling by mocking Location headers with 3xx status codes
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Mocks HTTP requests made by aiohttp's ClientSession for testing asynchronous code, supporting GET, POST, PUT, PATCH, DELETE, and OPTIONS methods with customizable status codes, bodies, headers, and JSON payloads.
Yes. aioresponses is a focused, well-maintained tool for a common testing need in async Python. It has no known vulnerabilities, low install friction, a permissive license, and active development. Install it if you write tests for code using aiohttp.
Install
aioresponses on PyPI
pip
pip install aioresponsesuv
uv add aioresponsespoetry
poetry add aioresponsesInstalling aioresponses
Before you install
Low friction install with just two runtime dependencies (packaging and aiohttp). Actively maintained with a recent release; repository shows steady activity and moderate community engagement.
License in practice
Permissive license allows unrestricted use in commercial and open-source projects without copyleft obligations.
Quickstart
pip install aioresponses
from aioresponses import aioresponses
import aiohttp
import asyncio
@aioresponses()
def test_example(mocked):
mocked.get('http://example.com', status=200, body='test')
session = aiohttp.ClientSession()
resp = asyncio.run(session.get('http://example.com'))
assert resp.status == 200
Requires Python 3.10+ and aiohttp>=3.8,<4.0
Verify before relying
- Whether the package supports Python 3.14 in practice (listed as classifier but may be aspirational)
Package facts
| License | not declared (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — packaging, aiohttp |
| Maintenance | actively maintained — 52 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 9,319,461/month — #1,546 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: aioresponses-0.7.9-py2.py3-none-any.whl
Tags
More WWW/HTTP packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
h11h11 is a pure-Python HTTP/1.1 protocol…
permissive · top 100 on PyPI
httpxHTTPX is a fully featured HTTP client library…
permissive · top 100 on PyPI
httpcoreA minimal low-level HTTP client library that…
permissive · top 100 on PyPI
aiohttpaiohttp is an async HTTP client and server…
permissive · top 100 on PyPI
aiohttp-xmlrpcProvides async XML-RPC server and client…
permissive · top 15,000 on PyPI
aiointerceptIntercepts aiohttp client requests by routing…
permissive · top 15,000 on PyPI
aresponsesMocks external HTTP/HTTPS services for…
permissive · top 15,000 on PyPI
requests-mockIntercepts and mocks HTTP requests made through…
permissive · top 1,000 on PyPI
responsesMocks HTTP requests made by the requests…
permissive · top 1,000 on PyPI
aiohttp-client-cacheAdds transparent request caching to…
permissive · top 15,000 on PyPI
urllib3-mockMocks urllib3 HTTP requests in tests by…
permissive · top 15,000 on PyPI
pytest-aiohttpPytest plugin that provides fixtures for…
permissive · top 5,000 on PyPI
aiohttp-asgi-connectorProvides an AIOHTTP connector that lets you…
permissive · top 15,000 on PyPI