gabrielfalcao

HTTPretty: Mock HTTP Requests Through Python Sockets

HTTPretty is a Python HTTP client mocking tool built on a fake TCP socket module. It intercepts requests so tests can supply responses and inspect captured traffic without depending on live APIs.

Stars
2.1k
Forks
285
Stars, last 29 days
-2
Last commit
2.4 years ago
Contributors
79

Our take

Inactiveno commits in over a year

Health score

31/100

How it is scored
Activity
20
Community
61
Issues
21
Pull requests
21

-2 stars in the last 29 days

HTTPretty offers a focused way to mock HTTP traffic in Python tests, but its inactive status makes current compatibility and maintenance worth checking before adopting it.

Good fit if

  • Your tests need to intercept HTTP requests through Python's socket layer and inspect the captured traffic.
  • You want to return controlled responses, including different statuses, without making live API calls.
  • An MIT-licensed Python dependency suits your project.

Look elsewhere if

  • You need a project with recent commits or releases: the repository has had no commits or releases in over a year.
  • You need evidence of active issue or pull-request handling: none were closed or merged in the recent measurement period.
  • Your Python version is outside the versions listed in the README and you require documented support.
All health signals
Last commit2024-06-09 (2.4 years ago)
Commits, last 90 days0
Releases, last 12 months0
Contributors79 (top contributor: 73% of commits)
Issues closed, last 90 days0
Pull requests merged, last 90 days0
Project age15 years

Checked on 2026-10-26 with the GitHub API.

Project history

Daily GitHub snapshots since Oct 7, 2026. History covers stars and forks; health signals are not tracked historically.

Selected snapshot

Stars

2,147

Forks

285

Change since Nov 4, 2026: 0 stars·0 forks

Overview

HTTPretty is a Python HTTP client mocking tool built around a fake TCP socket module. It intercepts HTTP requests at the socket level, letting tests substitute controlled responses for real network calls and inspect the requests made by the code under test.

It is intended for Python developers testing API integrations, especially when tests should not depend on external services. The README lists Python 3.6 through 3.9 as supported versions and describes inspiration from FakeWeb.

Key Features

  • Intercepts HTTP requests at the Python socket level.
  • Registers fake responses by HTTP method and URL.
  • Supports multiple registered responses for a URL, including different status codes.
  • Captures requests for inspection, including their bodies.
  • Can disallow live network connections while a test is active.
  • Provides an activation decorator for scoping the mock to a test.

Use Cases

  • API integration developers can test client behavior against deterministic responses instead of calling a live service.
  • Test authors can verify that code sends the expected method, URL, and request body.
  • Teams can exercise error handling by registering responses with failure status codes.
  • Developers using test-driven development can record and replay HTTP interactions while iterating on API-related code.

What you need

Detected in the repository

  • Python (from setup.py)
  • A test suite and automated checks on GitHub Actions

License in plain words

MITpermissive

  • Commercial use: yes
  • Modify and redistribute: yes
  • You must keep: the copyright and license notice
  • Share your changes: no

A summary, not legal advice: the LICENSE file is what applies.

Getting Started

Install from PyPI:

pip install httpretty

See the README and documentation for usage details.

Alternatives

  • httmock: httmock targets HTTP calls made through requests with conditional or catch-all responses, while HTTPretty intercepts traffic using a fake TCP socket.
  • python-mocket: Mocket intercepts socket and SSL traffic across HTTP and other protocols, while HTTPretty focuses on mocking HTTP through a fake TCP socket.
  • responses: Responses intercepts calls specifically from the Requests library, while HTTPretty works at the socket level for broader HTTP client coverage.
  • vcrpy: VCR.py records and replays HTTP interactions from cassette files, while HTTPretty lets tests define mocked responses and inspect captured requests.
ProjectLanguageLicenseStarsStatus
HTTPrettyPythonMIT2.1kInactive
httmockPython–471Inactive
python-mocketPythonBSD-3-Clause311Active
responsesPythonApache-2.04.3kActive
vcrpyPythonMIT3kQuiet

Considerations

The repository is marked inactive, with no commits in over a year and no releases in the past year. Although the project has contributions from many people, recent activity measures show no issue closures or merged pull requests, so teams should verify compatibility with their Python and HTTP-client versions themselves. The README lists Python 3.6 through 3.9, which may not establish support for newer runtimes. The project uses the MIT license; review its terms for your distribution and use.

Found this useful?

Share it with someone who would like HTTPretty.

Comparisons