skillfed

aresponses

Asyncio response mocking. Similar to the responses library used for 'requests'

aresponses v3.0.0 115.5K downloads/30d#12,245 on PyPI107
Permissive license DORMANT released

What it is and what it does

aresponses is a test fixture and mock server for asyncio applications that use aiohttp. It intercepts HTTP and HTTPS requests made by aiohttp.ClientSession and returns predefined responses without touching the network. You define routes using pattern matching (exact strings or regular expressions) on host, path, method, and body, then attach responses—plain text, JSON dicts, custom Response objects, or callable handlers. When your test code makes a request, aresponses matches it to the first registered route, returns the response, and removes that route from the table.

The package is designed for pytest integration and requires explicit assertions at the end of each test to verify that routes were called in order, all routes were used, and no unmatched requests occurred. It supports regex patterns for flexible matching, repeated routes via the repeat parameter, JSON responses as a convenience, custom handler functions, and a passthrough mode to let specific requests reach the real network. Version 3.0.0 updated to use asyncio.get_running_loop() instead of the deprecated event_loop fixture pattern.

Use it for:

  • Unit test an async client library or service that calls external APIs without making real HTTP requests.
  • Simulate error responses (500, timeouts, malformed JSON) to test error handling in async code.
  • Mock multiple external services in a single test by registering different routes for different hosts.
  • Verify that your async code calls external APIs in the correct order with the correct parameters.
  • Test HTTPS requests by transparently converting them to HTTP mocks without certificate setup.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Mocks external HTTP/HTTPS services for asyncio-based tests by intercepting aiohttp requests and returning predefined responses without making real network calls.

Yes, if you write asyncio tests with aiohttp. It has low install friction, no known vulnerabilities, permissive licensing, and is stable and widely used despite dormant maintenance. The trade-off: the last release was over 945 days ago, so if you need fixes for new Python or aiohttp versions, you may need to fork or wait for a maintainer response. For active projects on current Python (3.7–3.12), it works as-is.

Install

aresponses on PyPI

pip

pip install aresponses

uv

uv add aresponses

poetry

poetry add aresponses

Installing aresponses

Before you install

Low friction: pure Python wheel with only two runtime dependencies (pytest-asyncio and aiohttp). Maintenance is dormant—last release was 2024-01-12, over 945 days ago, though the repository remains active and the package is widely used (115539 monthly downloads).

License in practice

Licensed under MIT (permissive), so you can use it freely in commercial and private projects with minimal restrictions.

Quickstart

pip install aresponses

import aresponses
import aiohttp
import pytest

@pytest.mark.asyncio
async def test_mock(aresponses):
    aresponses.add("example.com", "/api", "GET", response="OK")
    async with aiohttp.ClientSession() as session:
        async with session.get("http://example.com/api") as resp:
            assert await resp.text() == "OK"
    aresponses.assert_plan_strictly_followed()

Requires pytest-asyncio to be installed and your test function decorated with @pytest.mark.asyncio; version 3.0.0 uses asyncio.get_running_loop() and may not work with older event loop patterns.

Verify before relying

  • Whether the dormant maintenance status (945 days since last release) poses a risk for future Python or aiohttp compatibility.
  • Performance characteristics when mocking high-volume or complex request/response patterns.
  • Compatibility with pytest-asyncio versions beyond what the fact sheet specifies.

Package facts

License not declared (permissive)
Python support supports the current Python release (>=3.7)
Install friction low — pure-Python wheel
Runtime dependencies 2 — pytest-asyncio, aiohttp
Maintenance dormant — 945 days since the last release
Last repo commit
First released
Downloads 115,539/month — #12,245 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: aresponses-3.0.0-py3-none-any.whl

Keywords: asyncio, testing, responses

License :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

Tags

asyncio http mockingaiohttp mock serverasync request mockingpytest asyncio fixturesnetwork service mockingasync testing utilitieshttp response stubbing
async-testinghttp-mocking

More Testing packages