requests-mock logo

requests-mock

Transport adapter that can mock out the Python requests library at the adapter level, useful for stubbing complex HTTP interactions.

-

Our Verdict

A solid choice for requests-based tests, though httpx users need respx and many teams prefer responses instead.

Pros

  • Mocks Python requests at the adapter level
  • Granular control over URL matching
  • Works as pytest fixture or decorator
  • No network needed for deterministic tests

Cons

  • Only works with requests library, not httpx
  • responses library is often considered simpler
  • Requires careful adapter scope management
Best for: Python code using requests where you need deterministic HTTP stubs Not for: httpx-based codebases where respx fits natively

When to Use requests-mock

Good fit if you need

  • Stub HTTP responses at the transport adapter layer
  • Context manager-based mocking for Python requests tests
  • Complex request matching with headers and body patterns
  • Prevent live API calls in Python integration test suites

Lock-in Assessment

Low 5/5
Lock-in Score
5/5

requests-mock Pricing

Pricing Model
free
Free Tier
Yes
Entry Price
Enterprise Available
No
Transparency Score

Beta — estimates may differ from actual pricing

1,000
1001K10K100K1M

Estimated Monthly Cost

$25

Estimated Annual Cost

$300

Estimates are approximate and may not reflect current pricing. Always check the official pricing page.

Project Health

F

Health Score

468 73
Bus Factor

2

Last Commit

1.8 years

Release Freq

259d

Open Issues

67

Issue Response

0d

License

Apache-2.0

Last checked: 2026-04-21

Community Discussion

Comments powered by Giscus (GitHub Discussions). You need a GitHub account to comment.