mocket
Socket Mock Framework - for all kinds of socket animals, web-clients included - with gevent/asyncio/SSL support
Decision gist · record as of 2026-08-14
Yes. Mocket is mature (active maintenance, 312 GitHub stars, no known vulnerabilities), has low install friction, and solves a real testing problem—isolating socket-based code from the network. Use it if you need to mock HTTP clients, test asyncio/gevent code, or build custom protocol mocks. The permissive BSD-3-Clause license poses no restriction.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Low friction: pure Python wheel with five lightweight runtime dependencies (decorator, h11, puremagic, typing-extensions, urllib3).
- Actively maintained with a recent release; last commit 2026-07-13.
- Supports modern Python versions (3.8–3.14) and PyPy.
License · maintenance · safety
BSD-3-Clause (permissive) — BSD-3-Clause (permissive): you can use, modify, and distribute mocket in proprietary projects without restriction, provided you include the license notice.
last release 2026-07-13 (32 days) · last repo commit 2026-07-13 · 312 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 261,074 downloads/mo, #8,388 on PyPI
Alternatives
Verify before relying
pip install mocket
from mocket import mocketize
from mocket.mocks.mockhttp import Entry
@mocketize
def test_api():
Entry.single_register(
Entry.GET,
'https://api.example.com/data',
body='{"key": "value"}',
headers={'content-type': 'application/json'}
)- Whether the Redis mock implementation is feature-complete enough for production test scenarios.
- Performance characteristics when mocking high-volume socket interactions.
- Compatibility with less common async frameworks beyond gevent and asyncio.
What it is and what it does
Mocket monkey-patches Python's socket and ssl modules to intercept network calls during testing, allowing you to define mock responses without touching the real network. It serves two roles: as a low-level framework for building custom protocol mocks (e.g., for new databases or protocols) and as a ready-to-use HTTP/HTTPS mock. The package includes a basic Redis mock and supports gevent, asyncio, and SSL out of the box.
You register mock entries with expected URLs, methods, and response bodies, then use a decorator or context manager to activate mocking for your test. Mocket also offers strict mode to fail tests that attempt real network access, and can verify that all registered mock entries were actually used. It depends on decorator, h11, puremagic, typing-extensions, and urllib3 at runtime.
Use it for
- Test HTTP/HTTPS clients without hitting real endpoints or rate limits.
- Mock HTTPS calls with SSL support in unit tests for web service integrations.
- Build custom protocol mocks for testing database clients or proprietary socket-based services.
- Enforce network isolation in CI/CD by using strict mode to fail tests that leak real socket calls.
- Test error paths by mocking socket exceptions and connection failures.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
Mocket is mature (active maintenance, 312 GitHub stars, no known vulnerabilities), has low install friction, and solves a real testing problem—isolating socket-based code from the network. Use it if you need to mock HTTP clients, test asyncio/gevent code, or build custom protocol mocks. The permissive BSD-3-Clause license poses no restriction.
Install
mocket on PyPI
Before you install
Low friction: pure Python wheel with five lightweight runtime dependencies (decorator, h11, puremagic, typing-extensions, urllib3). Actively maintained with a recent release; last commit 2026-07-13. Supports modern Python versions (3.8–3.14) and PyPy.
License in practice
BSD-3-Clause (permissive): you can use, modify, and distribute mocket in proprietary projects without restriction, provided you include the license notice.
Quickstart
pip install mocket
from mocket import mocketize
from mocket.mocks.mockhttp import Entry
@mocketize
def test_api():
Entry.single_register(
Entry.GET,
'https://api.example.com/data',
body='{"key": "value"}',
headers={'content-type': 'application/json'}
)
Verify before relying
- Whether the Redis mock implementation is feature-complete enough for production test scenarios.
- Performance characteristics when mocking high-volume socket interactions.
- Compatibility with less common async frameworks beyond gevent and asyncio.
Package facts
| License | BSD-3-Clause permissive |
| Python support | Supports the current Python release >=3.8 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 5 packagesdecoratorh11puremagictyping-extensionsurllib3 |
| Maintenance | Actively maintained 32 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 261,074 / month, #8,388 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 6 - MatureIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software DevelopmentTopic :: Software Development :: Testing |
Evidence: mocket-3.14.3-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 › “socket mocking framework”
- mocketMocket is a socket mocking framework that intercepts and replaces…
- aiointerceptIntercepts aiohttp client requests by routing them through a real…
- mockitoMockito is a spying and stubbing framework for Python that lets you…
Give your agent the search over MCP, or paste the wish link into any chat.
More Software Development packages
Provides backported and experimental type hints for Python 3.9+, allowing use of newer typing features on older Python versions and enabling early experimentation with type system PEPs before they enter the standard library.
NumPy provides an N-dimensional array object and a comprehensive suite of mathematical, linear algebra, Fourier transform, and random number functions for scientific computing in Python.
FastAPI is a Python web framework for building REST APIs using type hints, with automatic request validation, serialization, and interactive API documentation.
Provides a way to document function parameters, class attributes, return types, and variables inline using Python's `Annotated` type hint syntax instead of traditional docstrings.
Typer builds command-line applications from Python functions using type hints, automatically generating help text, argument parsing, and shell completion.
Install it if you are building CLIs in Python.
Distlib provides low-level packaging utilities for building, distributing, and managing Python software—including metadata handling, version specifiers, wheel support, script installation, and dependency resolution.
See also httmock · urllib3-mock · aiointercept · pook · responses · pytest-responses · wiremock · pytest-httpbin · pytest-localserver · moto-ext