Install & Compatibility
Where this runs
tested against v3.14.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.404s · 20MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 1.9s · import 0.374s · 20MB
18MB installed
● package 18MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Mocket
✓ from mocket import Mocket
Main mocket class for mocking socket calls.
MocketEntry
✓ from mocket import MocketEntry
Base class for defining mock responses.
mocketize
✓ from mocket import mocketize
Decorator/context manager to enable mocket sessions.
http.mock
✓ from mocket.plugins.httpretty import httpretty
✗ import httpretty
Do not use the standalone httpretty package; use mocket's plugin instead.
Basic usage mocking an HTTP GET request.
from mocket import mocketize, MocketEntry, Mocket
@mocketize
def test_http_get():
url = "http://example.com/"
Mocket.register(MocketEntry(url, body="mock response"))
import urllib.request
response = urllib.request.urlopen(url)
assert response.read() == b"mock response"
Errors
Common errors & fixes
ImportError: cannot import name 'httpretty' from 'mocket'
People try 'from mocket import httpretty' instead of using the plugin module.
fixUse 'from mocket.plugins.httpretty import httpretty'.
AttributeError: module 'mocket' has no attribute 'MocketEntry'
Old versions or import path changed; MocketEntry is directly in mocket module.
fixEnsure mocket version >= 3.0 and import as 'from mocket import MocketEntry'.
RuntimeError: Mocket not initialized. Use @mocketize decorator.
Attempting to use Mocket.register outside of a mocketized session.
fixWrap test function with @mocketize or use 'with mocketize():' block.
Upgrade
Version history
3.14.1latest on PyPI · released Feb 22, 2026
Audit
Dependencies
No dependency data recorded yet.