httmock
A mocking library for requests.
Decision gist · record as of 2026-08-14
Yes, if you need basic HTTP mocking for requests-based code and your project is on stable Python and requests versions. The dormant maintenance status means no new features or bug fixes, so verify compatibility first. For new projects or active development, consider whether a more actively maintained alternative better suits your needs.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Low friction install with a single lightweight dependency on requests.
- However, the package is dormant—last release was 2020-10-28, over five years ago, and no commits since 2023-09-29.
- It still works for its stated purpose but receives no active maintenance.
License · maintenance · safety
Apache-2.0 (permissive) — Licensed under Apache-2.0 (permissive), which allows commercial and private use with minimal restrictions—suitable for most projects.
last release 2020-10-28 (2116 days) · last repo commit 2023-09-29 · 472 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 1,973,040 downloads/mo, #3,393 on PyPI
Alternatives
Verify before relying
pip install httmock
from httmock import urlmatch, HTTMock
import requests
@urlmatch(netloc=r'example\.com$')
def mock_handler(url, request):
return {'status_code': 200, 'content': 'mocked response'}
with HTTMock(mock_handler):
r = requests.get('http://example.com/')
print(r.content)- Whether the package works reliably with modern versions of requests and Python 3.10+, given the dormant maintenance status.
- Whether urlmatch regex patterns and response handling remain compatible with current requests internals.
What it is and what it does
httmock is a mocking library that intercepts HTTP requests made by the requests library, letting you replace real API calls with predefined mock responses during testing. It works by decorating handler functions with urlmatch (to conditionally mock specific URLs) or all_requests (to mock all requests), then wrapping your test code in an HTTMock context manager. The library lets you return simple dictionaries or use the response() method to construct full HTTP responses with status codes, headers, and cookies.
The package is straightforward and has low install friction—it depends only on requests. However, it has been dormant since late 2020, with no active maintenance or updates. It remains functional for basic mocking tasks, but you should verify compatibility with your current Python and requests versions before relying on it in new projects.
Use it for
- Unit test code that calls third-party REST APIs without making real network requests.
- Mock specific API endpoints conditionally using URL patterns to test error handling and edge cases.
- Simulate API rate-limit responses or error codes to verify your application's retry logic.
- Test libraries or frameworks that use requests internally by intercepting their HTTP calls.
- Verify cookie handling and response headers in requests-based code without a live server.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you need basic HTTP mocking for requests-based code and your project is on stable Python and requests versions.
The dormant maintenance status means no new features or bug fixes, so verify compatibility first. For new projects or active development, consider whether a more actively maintained alternative better suits your needs.
Install
httmock on PyPI
Before you install
Low friction install with a single lightweight dependency on requests. However, the package is dormant—last release was 2020-10-28, over five years ago, and no commits since 2023-09-29. It still works for its stated purpose but receives no active maintenance.
License in practice
Licensed under Apache-2.0 (permissive), which allows commercial and private use with minimal restrictions—suitable for most projects.
Quickstart
pip install httmock
from httmock import urlmatch, HTTMock
import requests
@urlmatch(netloc=r'example\.com$')
def mock_handler(url, request):
return {'status_code': 200, 'content': 'mocked response'}
with HTTMock(mock_handler):
r = requests.get('http://example.com/')
print(r.content)
Verify before relying
- Whether the package works reliably with modern versions of requests and Python 3.10+, given the dormant maintenance status.
- Whether urlmatch regex patterns and response handling remain compatible with current requests internals.
Package facts
| License | Apache-2.0 permissive |
| Python support | Not specified |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packagerequests |
| Maintenance | Dormant 2,116 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,973,040 / month, #3,393 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Intended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseOperating System :: OS IndependentProgramming Language :: Python :: 2Programming Language :: Python :: 3Topic :: Software Development :: Testing |
Evidence: httmock-1.4.0-py3-none-any.whl
Tags
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 requests library”
- httmockIntercepts and mocks HTTP requests made by the requests library,…
- requests-mockIntercepts and mocks HTTP requests made through the requests library,…
- aiointerceptIntercepts aiohttp client requests by routing them through a real…
Give your agent the search over MCP, or paste the wish link into any chat.
More Testing packages
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.
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.
virtualenv creates isolated Python environments where packages can be installed independently without affecting the system Python or other projects.
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.
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.
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.
See also mocket · pytest-responses · smithy-http · wiremock · pook · aiointercept · requests-mock · responses · flexmock · http-exceptions