urllib3-mock
A utility library for mocking out the `urllib3` Python library.
What it is and what it does
urllib3-mock is a test utility that intercepts urllib3 HTTP calls and returns mock responses instead of making real network requests. It was adapted from the responses library and allows you to register predefined responses for specific URLs, or attach callbacks that generate responses dynamically based on request content. You can match URLs by exact string or compiled regex, set custom status codes and headers, or throw exceptions to simulate network failures.
The package is designed to work with urllib3 as bundled inside requests (requests.packages.urllib3). It has been abandoned since 2015; the latest release was 0.3.3 on 2015-04-16, and the repository has not been updated since 2023-01-17. It is only suitable for projects locked to very old versions of its target library.
Use it for:
- Unit test code that makes HTTP calls without making actual network requests.
- Mock specific API endpoints with fixed responses to test error handling and edge cases.
- Use request callbacks to simulate dynamic server behavior based on request body.
- Test code paths that depend on specific HTTP status codes or response headers.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Mocks urllib3 HTTP requests in tests by intercepting calls and returning predefined responses or callback-generated replies.
No. The package is abandoned (last release 2015-04-16, no commits since 2023-01-17) and designed for outdated bundled urllib3 in old requests versions. Modern projects should use alternative mocking libraries. Install only if you are maintaining legacy code locked to very old dependencies and cannot migrate.
Install
urllib3-mock on PyPI
pip
pip install urllib3-mockuv
uv add urllib3-mockpoetry
poetry add urllib3-mockInstalling urllib3-mock
Before you install
Low friction to install, but maintenance is abandoned—last release was 2015-04-16 and no commits since 2023-01-17. Use only if your project is locked to old urllib3 versions.
License in practice
Apache 2.0 is permissive; you may use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
Quickstart
from urllib3_mock import Responses
responses = Responses('requests.packages.urllib3')
@responses.activate
def test_api():
responses.add('GET', '/api/foobar', body='{"ok": true}', status=200)
assert len(responses.calls) == 0
Designed for requests.packages.urllib3 (bundled urllib3 in older requests versions); compatibility with current versions unknown.
Verify before relying
- Compatibility with current urllib3 and requests versions—package is abandoned and last tested in 2015.
- Whether regex URL matching and exception-throwing features work reliably in modern Python environments.
- Whether this package works with standalone urllib3 or only with bundled urllib3 in requests.
Package facts
| License | Apache 2.0 (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | abandoned — 4,138 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 150,538/month — #10,962 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: urllib3_mock-0.3.3-py2.py3-none-any.whl
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
pookpook intercepts and mocks HTTP traffic for…
permissive · top 15,000 on PyPI
responsesMocks HTTP requests made by the requests…
permissive · top 1,000 on PyPI
mocketMocket is a socket mocking framework that…
permissive · top 15,000 on PyPI
smithy-httpProvides HTTP primitives, interfaces, and…
permissive · top 15,000 on PyPI
pytest-responsesAutomatically mocks HTTP requests across your…
permissive · top 15,000 on PyPI
respxRESPX mocks HTTPX and HTTP Core libraries for…
permissive · top 1,000 on PyPI
aioresponsesMocks HTTP requests made by aiohttp's…
permissive · top 5,000 on PyPI
aresponsesMocks external HTTP/HTTPS services for…
permissive · top 15,000 on PyPI
betamaxBetamax records and replays HTTP interactions…
permissive · top 15,000 on PyPI
httptoolshttptools provides Python bindings for parsing…
permissive · top 1,000 on PyPI