RESPX
HTTP mocking library for Python's httpx client. RESPX intercepts httpx requests in tests and returns mocked responses without making real network calls. The async-native equivalent of responses (for requests) but designed for httpx. Essential for testing agent code that makes HTTP calls without hitting real APIs.
Score Breakdown
⚙ Agent Friendliness
🔒 Security
Testing library that prevents real network calls during tests — actually improves security by not hitting real APIs in test environments.
⚡ Reliability
Best When
Your agent code uses httpx for HTTP and you need clean, async-native HTTP mocking in pytest tests.
Avoid When
Your code uses requests (not httpx) — use the responses library. For httpx, RESPX is the best choice.
Use Cases
- • Mock external API calls in agent unit tests that use httpx for HTTP requests
- • Test agent error handling by simulating API failures, timeouts, and status codes with RESPX
- • Assert that agent code makes expected HTTP calls with correct URLs, headers, and payloads
- • Test async agent workflows that make multiple API calls with controlled mock responses
- • Build deterministic agent test suites that don't depend on external API availability
Not For
- • requests library mocking — use responses or responses-mock for requests (not httpx)
- • Integration testing against real APIs — use actual API calls or vcr-cassette recording
- • aiohttp mocking — use aioresponses for aiohttp client mocking
Interface
Authentication
Testing library — no authentication.
Pricing
Completely free and open source.
Agent Metadata
Known Gotchas
- ⚠ RESPX mocks httpx transports — only works with httpx clients; does not intercept requests, urllib3, or aiohttp
- ⚠ respx.mock() as context manager vs @respx.mock decorator — context manager for async tests, decorator for sync and async; mixing causes unmocked calls to leak
- ⚠ Unmatched routes raise httpx.ConnectError by default (assert_all_mocked=True) — in test setup this prevents real network calls but can be unexpected
- ⚠ Route matching is order-sensitive — more specific routes must be added before generic catch-all routes
- ⚠ Response side effects (raising exceptions) use side_effect= parameter — raising timeout or connection errors requires explicit side effect pattern
- ⚠ RESPX doesn't record/replay real responses — for cassette-style recording use pytest-recording or VCR.py with httpx support
Alternatives
Full Evaluation Report
Comprehensive deep-dive: security analysis, reliability audit, agent experience review, cost modeling, competitive positioning, and improvement roadmap for RESPX.
AI-powered analysis · PDF + markdown · Delivered within 30 minutes
Package Brief
Quick verdict, integration guide, cost projections, gotchas with workarounds, and alternatives comparison.
Delivered within 10 minutes
Score Monitoring
Get alerted when this package's AF, security, or reliability scores change significantly. Stay ahead of regressions.
Continuous monitoring
Scores are editorial opinions as of 2026-03-07.