CheckOps
responses
responses is an Apache-2.0 Python library from Sentry for mocking the Requests HTTP library, letting tests register fake responses, match request details and assert on calls.
- Unit Testing
- Python
- Open source
- Free
- Mocking
- API mocking
- Library
- Unit testing
- Integration testing
- API & contract testing
Latest public signals
Not refreshed yet. Refresh reads the public site and, when the entry has a GitHub repository, the latest release.
Introduction
responses is a utility for mocking out the Python Requests library, maintained by Sentry. It intercepts calls made with requests so tests never hit real servers; you register the responses you expect, and any unregistered request raises a ConnectionError, which makes accidental network calls obvious.
You activate it with the @responses.activate decorator or as a context manager, then call responses.add(...) (or helpers such as responses.get(...)) with the method, URL, status, body or JSON and headers. Matchers in responses.matchers check request details such as JSON bodies (json_params_matcher), URL-encoded form data and query parameters, so a stub only answers correctly formed requests. Callbacks generate dynamic responses, responses.calls records what was sent, registries control ordering, and options such as assert_all_requests_are_fired and passthrough prefixes are available on the mock. Version 0.26.3 was released on 26 August 2026.
The source code is at getsentry/responses on GitHub under the Apache-2.0 licence, with about 4,300 stars; the most recent commit was on 3 November 2026.
Features
- Requests mocking: Intercepts the requests library without network calls.
- Request matchers: Match JSON, form data and query parameters.
- Call inspection:
responses.callsrecords requests for assertions. - Strict by default: Unregistered requests fail loudly.
Pros
- Free to use: Open source under the Apache-2.0 licence, so the core tool costs nothing to use.
- Actively maintained: The repository had commits as recent as 3 November 2026.
- Community: About 4,300 GitHub stars.
Cons
- Requests only: Does not mock httpx, aiohttp or urllib directly.
- Manual stubs: Large APIs need many registrations; VCR.py records them instead.
Usage and Links (Example)
import requests
import responses
from responses import matchers
@responses.activate
def test_create_user():
responses.post(
"https://api.example.com/users",
json={"id": 1},
status=201,
match=[matchers.json_params_matcher({"name": "Ana"})],
)
r = requests.post("https://api.example.com/users", json={"name": "Ana"})
assert r.status_code == 201
assert len(responses.calls) == 1
Resources:
Pricing
responses is free and open source under the Apache-2.0 licence.
Recommended for?
- Python code that uses requests and needs fast, isolated tests.
- Teams that want strict checks that requests are well formed.
Conclusion
responses is the go-to mocking library for requests-based Python code, simple, strict and well maintained by Sentry.
Alternatives
Other tools on CheckOps that cover similar ground. Open a page, or compare one with responses side by side.
VVCR.pyVCR.py is an MIT-licensed Python library, ported from Ruby's VCR, that records HTTP interactions to cassette files and replays them in later test runs for fast, deterministic, offline tests.Compare with responses- Ppytestpytest is the usual Python test runner: plain asserts, fixtures, parametrization, and a large plugin set.Compare with responses
MMock Service Worker (MSW)Mock Service Worker (MSW) is an MIT-licensed API mocking library that intercepts network requests at the network level in browsers (via a Service Worker) and Node.js, for REST, GraphQL and WebSocket APIs.Compare with responses
NNockHTTP server mocking and expectations library for Node.js.Compare with responses
WWireMockA tool for mocking HTTP services.Compare with responses
PPython unittestunittest is Python's built-in xUnit-style testing framework, with TestCase classes, fixtures, test discovery, subtests, async test cases and the unittest.mock library, available in every Python install.Compare with responses