An asyncio testing server for mocking external HTTP services, similar to the responses library but for aiohttp.
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.
Python developers writing asynchronous applications with aiohttp who need to mock external HTTP services in their unit and integration tests.
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.
Asyncio http mocking. Similar to the responses library used for 'requests'
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses actual network connections for mocking, including HTTPS support by switching to HTTP, making tests realistic without external dependencies.
Supports regex matching for host, path, method, and request body, allowing precise control over which requests to mock.
Requires explicit verification with functions like assert_plan_strictly_followed(), reducing flaky tests and improving maintainability.
Tracks all intercepted requests in a history log, enabling easy inspection and debugging of HTTP interactions during tests.
Designed solely for aiohttp, so it's incompatible with other HTTP clients like requests, restricting its use in mixed or non-aiohttp projects.
Version 2.0 introduced breaking changes, such as mandatory explicit assertions, which can disrupt existing test suites and require migration effort.
Integration with pytest-aiohttp requires extra fixture configuration, as noted in the README, adding overhead for some testing setups.