responses vs httmock
Python requests HTTP mocking libraries compared
responses and httmock intercept HTTP calls made with Python's `requests` library and provide mocked responses for tests. responses documents more request-matching, callback, call-inspection, and response-sequencing options, while httmock offers URL-based matching and configurable response helpers.

responses: Mock Python Requests in Tests
Responses intercepts Python Requests calls and serves registered mock responses, so tests can exercise HTTP client code without contacting real services. It supports request matching, callbacks, call assertions, and ordered response sequences.

httmock: Mock HTTP Requests for Python Tests
httmock is a Python library built on requests for mocking HTTP interactions in tests. It lets you provide conditional or catch-all mocked responses when testing code that calls APIs through requests.
| responses | httmock | |
|---|---|---|
| Language | Python | Python |
| License | Apache-2.0 | — |
| Stars | 4.3k | 471 |
| Forks | 386 | 57 |
| Last analyzed | Oct 3, 2026 | Oct 19, 2026 |
Key differences
- responses supports matching request bodies, headers, query parameters, multipart data, fragments, and selected arguments; httmock documents URL matching with `urlmatch`.
- responses supports callbacks, recorded call inspection, call-count assertions, and ordered response registries; httmock documents response handlers using `HTTMock` and `all_requests`.
- responses can be activated with a decorator, context manager, or explicit start and stop calls; httmock documents activation through an `HTTMock` context manager.
- responses requires Python 3.8 or newer and `requests` 2.30.0 or newer; httmock documents Python 2.7 and Python 3.4+ support.
- responses lists its license as Apache-2.0; httmock lists its license as `NOASSERTION`, which should be verified before adoption where licensing matters.
- responses reports 4.3k stars and 386 forks; httmock reports 472 stars and 56 forks.
Choose responses if you…
- need detailed request matching, including bodies, headers, and query parameters.
- want callbacks, call assertions, or ordered responses to model changing server behavior.
- need passthrough rules or want to record and replay responses, noting that recording and replay are labeled beta.
Choose httmock if you…
- want URL-based matching with `urlmatch` or handling all requests with `all_requests`.
- need mocked responses with configurable status, content, headers, or cookies.
- need a project whose README documents Python 2.7 support, or Python 3.4+ support, and will verify compatibility with your environment.
Compare the numbers side by side, or add more projects
This comparison is generated with AI from the OSRepos analyses of both projects. Always check each project's repository and documentation before choosing.