responses (Python)

Mock library for the Python requests library. responses intercepts requests.get/post/put/delete calls and returns registered mock responses, capturing the outgoing request details. Unlike HTTPretty (socket-level), responses patches requests specifically — providing better request inspection (what URL was called, what headers were sent, how many times). Maintained by Sentry — widely used for testing requests-based agent code.

Evaluated Mar 06, 2026 (0d ago) v0.25+
Homepage ↗ Repo ↗ Developer Tools python testing http mocking requests sentry open-source unit-testing
⚙ Agent Friendliness
68
/ 100
Can an agent use this?
🔒 Security
90
/ 100
Is it safe for agents?
⚡ Reliability
87
/ 100
Does it work consistently?

Score Breakdown

⚙ Agent Friendliness

MCP Quality
--
Documentation
88
Error Messages
85
Auth Simplicity
100
Rate Limits
95

🔒 Security

TLS Enforcement
90
Auth Strength
90
Scope Granularity
88
Dep. Hygiene
90
Secret Handling
90

Local testing library — no network calls when properly configured. ConnectionError for unregistered URLs prevents accidental real API calls.

⚡ Reliability

Uptime/SLA
88
Version Stability
88
Breaking Changes
85
Error Recovery
88
AF Security Reliability

Best When

Your Python agent code uses the requests library and you need HTTP mocking with request inspection — responses provides the cleanest API for requests-specific testing.

Avoid When

You're using httpx (use respx), aiohttp (use aioresponses), or need to mock multiple HTTP libraries in the same test suite.

Use Cases

  • Mock HTTP API calls in Python agent unit tests using requests — register URL patterns with mock responses and verify calls were made
  • Inspect what HTTP requests agent code makes — responses captures call count, URL, body, headers for assertion in tests
  • Simulate API error conditions for agent resilience tests — register 429, 500, or ConnectionError responses for specific endpoints
  • Test agent retry logic with response sequences — register multiple responses for the same URL that return different values per call
  • Passthrough specific URLs to real servers during testing while mocking others — responses.add_passthrough() for selective interception

Not For

  • Code using httpx or aiohttp — responses only works with requests library; use respx for httpx
  • Tests needing socket-level interception across multiple HTTP libraries — use HTTPretty for multi-library mocking
  • Async tests with aiohttp — use aioresponses for aiohttp-specific mocking

Interface

REST API
No
GraphQL
No
gRPC
No
MCP Server
No
SDK
Yes
Webhooks
No

Authentication

Methods: none
OAuth: No Scopes: No

Local testing library — no external auth or network calls during test.

Pricing

Model: open_source
Free tier: Yes
Requires CC: No

Apache 2.0 licensed open source maintained by Sentry.

Agent Metadata

Pagination
none
Idempotent
Full
Retry Guidance
Not documented

Known Gotchas

  • responses only intercepts the requests library — code that uses urllib, httpx, or aiohttp will bypass the mock and make real network calls; verify all HTTP clients are requests-based
  • By default, calling an unregistered URL raises ConnectionError — use responses.passthrough_prefixes or assert_all_requests_are_fired=False to control handling of unexpected requests
  • responses.calls tracks all intercepted requests — long test sessions accumulate calls; use responses.reset() between tests if using the module-level API instead of decorators
  • URL matching is exact by default — query parameter order matters unless using match_querystring=False or URL pattern matching with re.compile()
  • Registering the same URL multiple times creates a response queue — first call uses first response, second call uses second; running out of registered responses raises ConnectionError
  • responses doesn't support streaming responses — agent code that calls iter_content() or iter_lines() may not behave the same as with real streaming HTTP responses

Alternatives

Full Evaluation Report

Detailed scoring breakdown, competitive positioning, security analysis, and improvement recommendations for responses (Python).

$99

Scores are editorial opinions as of 2026-03-06.

5215
Packages Evaluated
26151
Need Evaluation
173
Need Re-evaluation
Community Powered