python-mocket vs httmock
Python HTTP testing mocks compared
python-mocket and httmock both help Python developers test network-facing code without relying on live services. python-mocket works at the socket and SSL level and supports more than HTTP, while httmock focuses on HTTP calls made through requests.

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.

httmock: Mock HTTP Requests for Python Tests
httmock is a Python library built on requests for mocking HTTP interactions in tests. It lets you provide conditional or catch-all mocked responses when testing code that calls APIs through requests.
| python-mocket | httmock | |
|---|---|---|
| Language | Python | Python |
| License | BSD-3-Clause | — |
| Stars | 311 | 471 |
| Forks | 51 | 57 |
| Last analyzed | Oct 3, 2026 | Oct 19, 2026 |
Key differences
- python-mocket patches socket and SSL behavior for HTTP, HTTPS, and lower-level protocols; httmock intercepts HTTP calls made with requests.
- python-mocket supports synchronous and asynchronous clients, including aiohttp; httmock is built around requests.
- python-mocket offers strict network blocking and custom socket-level mocks; httmock provides URL-based or catch-all HTTP handlers within a test context.
- python-mocket is licensed under BSD-3-Clause; httmock's license is reported as NOASSERTION, so review its license files before use.
- httmock has more reported stars and forks, while its repository is marked inactive with no commits in over a year; python-mocket is not marked archived.
Choose python-mocket if you…
- need to mock socket traffic beyond requests-based HTTP calls.
- want strict blocking of unmocked network access or asyncio client support.
- need to simulate socket errors, record traffic, or build custom protocol mocks.
Choose httmock if you…
- use requests and want to mock its HTTP calls with a focused library.
- want to match requests by URL or intercept all requests in a test context.
- need to control response status codes, content, headers, and cookies.
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.