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.

HTTPrettypython-mocket
LanguagePythonPython
LicenseMITBSD-3-Clause
Stars2.1k311
Forks28551
Last analyzedOct 3, 2026Oct 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.
Read the HTTPretty analysis →

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.
Read the python-mocket analysis →

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.