HTTPretty vs httmock

Python HTTP mocking libraries compared

HTTPretty and httmock both help Python tests use mocked HTTP responses instead of relying on live services. HTTPretty intercepts traffic at the socket level, while httmock targets requests made through the `requests` library.

HTTPrettyhttmock
LanguagePythonPython
LicenseMIT—
Stars2.1k471
Forks28557
Last analyzedOct 3, 2026Oct 19, 2026

Key differences

  • HTTPretty intercepts Python HTTP traffic at the socket level; httmock intercepts calls made through `requests`.
  • HTTPretty registers fakes by HTTP method and URL and can return multiple responses for repeated requests; httmock offers URL matching with `urlmatch` and handlers for all requests in a test context.
  • HTTPretty can capture requests for inspecting bodies and counts; httmock provides configurable response status codes, content, headers, and cookies.
  • HTTPretty lists Python 3.6 through 3.9 as supported; httmock lists Python 2.7 and Python 3.4+.
  • HTTPretty reports an MIT license, 2.1k stars, and 285 forks; httmock reports `NOASSERTION`, 472 stars, and 56 forks.

Choose HTTPretty if you…

  • need socket-level interception rather than interception limited to `requests`.
  • want to inspect captured request bodies or counts, or test successive responses to the same URL.
  • need the reported MIT license.
Read the HTTPretty analysis →

Choose httmock if you…

  • use the `requests` library and want handlers scoped with a context manager.
  • want URL-based matching or response controls for status codes, headers, cookies, and content.
  • need the documented Python 2.7 support, or Python 3.4+ support.
Read the httmock 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.