--- id: mocket version: "3.14.3" license: BSD-3-Clause license_treatment: permissive maintenance: active --- # mocket — Socket Mock Framework - for all kinds of socket animals, web-clients included - with gevent/asyncio/SSL support License: permissive · Maintenance: active · Downloads: 261.1K/mo ## 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 above — verify before relying. Mocket is a socket mocking framework that intercepts and replaces socket and SSL module calls, enabling you to test socket-based clients without real network traffic. 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 pip install mocket uv add mocket poetry add mocket ## Installing mocket 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_current - Install friction: low - Maintenance: active - Downloads: 261.1K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags socket mocking framework, mock http requests testing, intercept socket calls, test without network, asyncio socket mock, ssl mock testing, gevent socket mocking, testing-framework, socket-mocking, asyncio-support [View on SkillFed](https://skillfed.io/packages/mocket) · [View on PyPI](https://pypi.org/project/mocket/)