HTTPretty vs python-mocket
Python socket mocking libraries compared
HTTPretty and python-mocket both intercept network traffic so Python tests can use mocked responses instead of live services. HTTPretty focuses on HTTP requests, while python-mocket also supports HTTPS, asyncio clients, and custom socket protocols.

HTTPretty: Mock HTTP Requests in Python Tests
HTTPretty intercepts Python HTTP traffic at the socket level and returns registered fake responses. It helps developers test API integrations without relying on live services, and can capture requests for assertions or playback.

python-mocket: Mock Socket Traffic for Python Tests
Mocket lets Python developers intercept socket and SSL traffic so tests can mock HTTP and other protocol clients without making real network requests. It supports synchronous and asynchronous clients, strict network blocking, and custom socket-level mocks.
| HTTPretty | python-mocket | |
|---|---|---|
| Language | Python | Python |
| License | MIT | BSD-3-Clause |
| Stars | 2.1k | 311 |
| Forks | 285 | 51 |
| Last analyzed | Oct 3, 2026 | Oct 3, 2026 |
Key differences
- HTTPretty registers fakes by HTTP method and URL, while python-mocket can match requests with callbacks that inspect paths and parsed query parameters.
- python-mocket offers strict mode to raise on unmocked network access; HTTPretty supports disabling network connections during a test.
- python-mocket supports asyncio clients and custom socket-protocol mocks, including basic Redis examples; HTTPretty focuses on HTTP traffic.
- HTTPretty can capture requests for assertions, while python-mocket can record real socket traffic to JSON files for reuse in tests.
- HTTPretty uses the MIT license, while python-mocket uses the BSD-3-Clause license.
- The provided facts list 2.1k stars and 285 forks for HTTPretty, compared with 311 stars and 51 forks for python-mocket. Both are unarchived Python projects.
Choose HTTPretty if you…
- need HTTP-focused fakes registered by method and URL.
- want to inspect captured request bodies or counts in tests.
- want a test decorator to activate interception around a test.
Choose python-mocket if you…
- need to mock HTTPS, asyncio clients, or custom socket protocols.
- want strict mode to fail tests that attempt unmocked network access.
- need to simulate socket exceptions or save recorded traffic to JSON for reuse.
Compare the numbers side by side, or add more projects
This comparison is generated with AI from the OSRepos analyses of both projects. Always check each project's repository and documentation before choosing.