skillfed

urllib3-mock

A utility library for mocking out the `urllib3` Python library.

urllib3-mock v0.3.3 150.5K downloads/30d#10,962 on PyPI13
Permissive license Apache 2.0 Abandoned released

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-mock

uv

uv add urllib3-mock

poetry

poetry add urllib3-mock

Installing 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

Intended Audience :: DevelopersIntended Audience :: System AdministratorsOperating System :: OS IndependentProgramming Language :: Python :: 2Programming Language :: Python :: 3Topic :: Software Development

Tags

mock urllib3 requestsurllib3 test mockinghttp request mockingfake urllib3 responsestest http callsurllib3 testing utility
http-mockinglegacy-package

More Software Development packages