$npx skillfedfor your agent

requests-mock

Mock out responses from the requests package

Worth itPyPI TestingReleased Mar 202428.7M downloads / moApache-2Pure Python

Decision gist · record as of 2026-08-14

pure-Python wheel — requests_mock-1.12.1-py2.py3-none-any.whl
v1.12.1 · released 2024-03-29 · Python >=3.5 · 1 runtime deps: requests

Yes. This is a stable, low-friction testing utility for any project using requests. It has no security vulnerabilities, a permissive license, and a single lightweight dependency. The dormant maintenance status is not a concern for a mature, narrowly-scoped library—it does one thing well and requires little ongoing change. Install it if you write tests for code that makes HTTP calls.AI-flagged interpretation of the facts on this page — verify before relying

Before you install

  • Low friction: pure Python wheel with a single runtime dependency (requests).
  • Maintenance is dormant—last release was 2024-03-29 and last commit 2024-07-15—but the package is marked Production/Stable and has seen no recent changes needed.

License · maintenance · safety

Apache-2 (permissive) — Apache-2 (permissive): you can use this freely in commercial and open-source projects, modify it, and distribute it with minimal restrictions—no copyleft obligation.

last release 2024-03-29 (868 days) · last repo commit 2024-07-15 · 466 stars

0 known vulnerabilities (OSV.dev, 2026-08-14) · 28,678,227 downloads/mo, #830 on PyPI

Verify before relying

import requests
import requests_mock

with requests_mock.Mocker() as m:
    m.get('http://test.com', text='data')
    resp = requests.get('http://test.com')
    print(resp.text)  # 'data'
Same gist for agents: .md · .json

What it is and what it does

requests-mock is a testing library that intercepts calls made through the requests library and returns pre-defined mock responses instead of making real HTTP requests. It works by registering a custom adapter with a requests Session, allowing you to stub out specific URIs and their responses. This is useful for unit and integration tests where you want to verify your code's HTTP logic without depending on external services or network availability.

The library supports three main usage patterns: mounting an adapter directly to a Session, using it as a context manager, or using it as a pytest fixture. You register mock responses by specifying a method (GET, POST, etc.), a URI pattern, and the response body or status code. When your code makes a matching request, the mock adapter intercepts it and returns your predefined response.

Use it for

  • Unit test code that calls external REST APIs without requiring network access or test credentials.
  • Verify error handling by mocking specific HTTP status codes and error responses.
  • Test request/response logic in isolation by stubbing out third-party service calls.
  • Simulate slow or unreliable network conditions for resilience testing.
  • Run tests in CI/CD pipelines without external service dependencies.

Worth the install?

AI-flagged interpretation of the facts on this page. Verify before relying on it.

Worth it

Yes.

This is a stable, low-friction testing utility for any project using requests. It has no security vulnerabilities, a permissive license, and a single lightweight dependency. The dormant maintenance status is not a concern for a mature, narrowly-scoped library—it does one thing well and requires little ongoing change. Install it if you write tests for code that makes HTTP calls.

Install

requests-mock on PyPI

Before you install

Low friction: pure Python wheel with a single runtime dependency (requests). Maintenance is dormant—last release was 2024-03-29 and last commit 2024-07-15—but the package is marked Production/Stable and has seen no recent changes needed.

License in practice

Apache-2 (permissive): you can use this freely in commercial and open-source projects, modify it, and distribute it with minimal restrictions—no copyleft obligation.

Quickstart

import requests
import requests_mock

with requests_mock.Mocker() as m:
    m.get('http://test.com', text='data')
    resp = requests.get('http://test.com')
    print(resp.text)  # 'data'

Package facts

LicenseApache-2 permissive
Python supportSupports the current Python release >=3.5
Install frictionLow. Pure-Python wheel
Runtime dependencies
1 package
requests
MaintenanceDormant 868 days since the last release
Last repo commit
First released
Downloads28,678,227 / month, #830 on PyPI 30-day window, as of 2026-08-14
Known vulnerabilitiesNone known OSV.dev, checked 2026-08-14
Classifiers
Development Status :: 5 - Production/StableIntended Audience :: DevelopersIntended Audience :: Information TechnologyLicense :: OSI Approved :: Apache Software LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: Testing

Evidence: requests_mock-1.12.1-py2.py3-none-any.whl

Tags

Capabilities
mock http requests in testsstub requests library responsesfake http adapter for testingrequests testing mockintercept http calls in testsrequests library test doublesmock rest api responses
Topics
testinghttp-mockingrequests-library

Let your AI agent find packages like this

Example. Real query, live index.

You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.

wish › “mock http requests in tests”

  • requests-mockIntercepts and mocks HTTP requests made through the requests library,…
  • httmockIntercepts and mocks HTTP requests made by the requests library,…
  • pytest-httpx2A pytest plugin that mocks httpx2 HTTP requests using respx, letting…

Give your agent the search over MCP, or paste the wish link into any chat.

More Testing packages

pluggy Worth it
PyPI · Libraries · released May 2025

Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.

Install it if you're building an extensible application or framework.

MITpure Python · 3.9+aging
1.3Bdownloads / mo
pytest Worth it
PyPI · Libraries · released Jun 2026

pytest is a testing framework that lets you write test functions using plain assert statements and automatically discovers and runs them, with detailed failure reporting.

MITpure Python · 3.10+
1.1Bdownloads / mo
virtualenv Worth it
PyPI · Libraries · released Aug 2026

virtualenv creates isolated Python environments where packages can be installed independently without affecting the system Python or other projects.

MITpure Python · 3.9+
532.9Mdownloads / mo
coverage Worth it
PyPI · Testing · released Aug 2026

Coverage.py measures which lines of Python code are executed during test runs, reporting coverage percentages and identifying untested code paths.

Install it if you want to measure test completeness or enforce coverage thresholds in your project.

permissive licensepure Python · 3.10+
335.8Mdownloads / mo
pytest-asyncio Worth it
PyPI · Testing · released May 2026

pytest-asyncio is a pytest plugin that enables writing and running async test functions using the asyncio library, allowing developers to await code directly within test cases.

Install it if you write tests for any asyncio-based code.

Apache-2.0pure Python · 3.10+
275.9Mdownloads / mo
pytest-json-ctrf Worth it
PyPI · Testing · released Jul 2026

A pytest plugin that generates test reports in Common Test Report Format (CTRF) as JSON, compatible with pytest-xdist and pytest-playwright for distributed and browser-based testing.

Install it if you need CTRF-formatted test output for CI/CD integration or cross-tool reporting.

MITpure Python · 3.8+
273.0Mdownloads / mo

See also responses · httmock · requests-file · aioresponses · mockito · aiointercept · mock · pretend · pytest-responses · pook