getsentry

responses: Mock HTTP Calls Made with Python Requests

responses is a Python utility built on the Requests library for mocking HTTP calls in tests. Register expected requests and return controlled responses to test API clients without relying on live services.

ActivePythonApache-2.0LibraryTestingHTTP Mocking
View on GitHub Compare
Stars
4.3k
Forks
389
Stars, last 30 days
+0
Last commit
22 days ago
Contributors
100+

Our take

Activeregular commits and releases

Health score

52/100

How it is scored
Activity
51
Community
88
Issues
35
Pull requests
33

+0 stars in the last 30 days

  • More contributors than 78% of the projects we track
  • Slower to merge pull requests than 91% of the projects we track

A focused Requests testing library with broad matching and response-control options, backed by recent releases and contributions from a broad contributor base, though reported issue resolution is relatively slow.

Good fit if

  • Your Python code uses Requests and tests need deterministic HTTP responses.
  • You need request matchers, callbacks, ordered responses, or call assertions.
  • You want a project with recent commits and releases and no measured reliance on a single contributor.

Look elsewhere if

  • Your HTTP client is not Requests, since this library is specifically built to mock Requests.
  • Your project cannot use Python 3.8 or newer, or Requests 2.30.0 or newer.
  • Your workflow requires quick issue resolution, since the reported median time to close issues is several months.
All health signals
Last commit2026-10-06 (22 days ago)
Commits, last 90 days11
Releases, last 12 months4 (latest 0.26.3, 2026-08-26)
Contributors100+ (top contributor: 31% of commits)
Issues closed, last 90 days3 (typically closed in 156 days)
Pull requests merged, last 90 days9 (typically merged in 6 days)
Project age12 years

Checked on 2026-10-29 with the GitHub API.

Project history

Daily GitHub snapshots since Oct 7, 2026. History covers stars and forks; health signals are not tracked historically.

Selected snapshot

Stars

4,342

Forks

393

Change since Nov 13, 2026: 0 stars·0 forks

Overview

responses is a Python utility for mocking HTTP calls made with the Requests library. It intercepts requests in tests and returns registered or callback-generated responses, so teams can exercise API client behavior without depending on a live server.

It is aimed at Python developers testing code that uses Requests, from simple GET and POST calls to request matching, redirects, retries, and concurrent calls. Tests can use a decorator or a context manager, and unmatched requests raise a connection error unless configured to pass through.

Key Features

  • Register mock responses by HTTP method and URL, with status, body, JSON, and headers.
  • Match requests by JSON or URL-encoded body, query parameters, headers, multipart data, fragments, and selected request arguments.
  • Generate responses dynamically with callbacks, including callbacks that inspect request data.
  • Choose default or ordered response registries to control how repeated requests are served.
  • Inspect recorded calls and assert response call counts.
  • Exercise error cases, redirects, and retry behavior without contacting the target service.
  • Allow selected requests to pass through to real servers.
  • Record real responses to YAML files and load them into a mock registry, a feature the project labels beta.

Use Cases

  • A Python developer can test an API client’s handling of success and error responses without a network dependency.
  • A team can verify that code sends the expected JSON payload, query parameters, or headers before accepting a mocked response.
  • A maintainer can test retry limits and response sequences by registering ordered responses for repeated requests.
  • A test author can simulate redirects, connection errors, or dynamic server behavior to cover less common paths.

What you need

Detected in the repository

  • Python (from pyproject.toml)
  • Automated checks on GitHub Actions

License in plain words

Apache-2.0permissive

  • Commercial use: yes
  • Modify and redistribute: yes
  • You must keep: the license, the NOTICE file and a note of your changes
  • Share your changes: no
  • Includes an explicit patent grant from the contributors:

A summary, not legal advice: the LICENSE file is what applies.

Getting Started

Install with:

pip install responses

See the README for usage details, matchers, and configuration options.

Alternatives

  • httmock: httmock matches requests by URL or handler and supplies responses, rather than using responses' request-registration interface.
  • HTTPretty: HTTPretty intercepts traffic through fake sockets, while responses mocks at the Requests library level.
  • python-mocket: Mocket intercepts socket and SSL traffic across multiple clients and protocols, rather than targeting Requests alone.
  • vcrpy: VCR.py records and replays HTTP exchanges from cassette files, rather than defining mocked responses directly in tests.
ProjectLanguageLicenseStarsStatus
responsesPythonApache-2.04.3kActive
httmockPython–471Inactive
HTTPrettyPythonMIT2.1kInactive
python-mocketPythonBSD-3-Clause311Active
vcrpyPythonMIT3kQuiet

Considerations

The library requires Python 3.8 or newer and Requests 2.30.0 or newer. The README identifies recording and replay from YAML files as beta functionality, so teams relying on those APIs should account for possible changes. The project is actively maintained, with recent commits and releases; its contributor base is not concentrated around one person. Issue closure is slower than pull request merging according to the supplied health data. The repository uses the Apache-2.0 license.

Found this useful?

Share it with someone who would like responses.

Comparisons