Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Asyncio
  3. aresponses

aresponses

MITPython

An asyncio testing server for mocking external HTTP services, similar to the responses library but for aiohttp.

GitHubGitHub
108 stars20 forks0 contributors

What is aresponses?

aresponses is an asyncio HTTP mocking library for Python that intercepts and mocks outgoing HTTP requests made with aiohttp. It allows developers to simulate external API responses, network errors, and various server behaviors during testing, ensuring tests are fast, reliable, and isolated from real network dependencies.

Target Audience

Python developers writing asynchronous applications with aiohttp who need to mock external HTTP services in their unit and integration tests.

Value Proposition

It provides a straightforward, network-aware mocking solution specifically designed for asyncio and aiohttp, with features like regex matching, explicit assertions, and request history that make test writing and debugging more efficient compared to manual stubbing.

Overview

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

Use Cases

Best For

  • Mocking third-party API calls in aiohttp-based applications
  • Testing error handling for network failures and HTTP status codes
  • Simulating different API response scenarios (JSON, text, errors) in unit tests
  • Verifying the order and correctness of HTTP requests made during test execution
  • Isolating tests from flaky or slow external services
  • Testing HTTPS endpoints by mocking them as HTTP requests

Not Ideal For

  • Projects using synchronous HTTP libraries like requests or urllib instead of aiohttp
  • Teams preferring implicit mock verification without manual assertion calls
  • Applications needing to mock non-HTTP network protocols or services
  • Test suites where avoiding network layer overhead for speed is critical

Pros & Cons

Pros

Network-Based Realism

Uses actual network connections for mocking, including HTTPS support by switching to HTTP, making tests realistic without external dependencies.

Flexible Pattern Matching

Supports regex matching for host, path, method, and request body, allowing precise control over which requests to mock.

Explicit Assertions

Requires explicit verification with functions like assert_plan_strictly_followed(), reducing flaky tests and improving maintainability.

Comprehensive Request History

Tracks all intercepted requests in a history log, enabling easy inspection and debugging of HTTP interactions during tests.

Cons

aiohttp-Only Limitation

Designed solely for aiohttp, so it's incompatible with other HTTP clients like requests, restricting its use in mixed or non-aiohttp projects.

Breaking Changes Risk

Version 2.0 introduced breaking changes, such as mandatory explicit assertions, which can disrupt existing test suites and require migration effort.

Setup Complexity

Integration with pytest-aiohttp requires extra fixture configuration, as noted in the README, adding overhead for some testing setups.

Frequently Asked Questions

Quick Stats

Stars108
Forks20
Contributors0
Open Issues3
Last commit2 years ago
CreatedSince 2017

Tags

#asyncio#aiohttp#pytest#unit-testing#network-testing#test-doubles#python#testing#http-mocking

Built With

a
aiohttp
P
Python
p
pytest

Included in

Asyncio5.0k
Auto-fetched 16 hours ago

Related Projects

pytest-asynciopytest-asyncio

Asyncio support for pytest

Stars1,651
Forks197
Last commit1 day ago
aioresponsesaioresponses

Aioresponses is a helper for mock/fake web requests in python aiohttp package.

Stars558
Forks105
Last commit1 month ago
asynctestasynctest

Enhance the standard unittest package with features for testing asyncio libraries

Stars310
Forks42
Last commit2 years ago
aiomockaiomock

a version of pythons unittest.Mock with async methods

Stars28
Forks0
Last commit2 years ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub