Skip to main content

httpmock

Fluent API for mocking HTTP requests in Python tests

Sponsor Joseph Hale Joseph Hale's software engineering blog Follow Joseph Hale!

httpmock is essentially a thin wrapper around httpretty to give it a more fluent interface.

Example usage:

import httpmock
import requests

@httpmock.enabled
def test_something():
    httpmock.on("GET", "http://example.com").respond(body="Hello, world!")
    assert requests.get("http://example.com").text == "Hello, world!"

Documentation for httpretty: https://httpretty.readthedocs.io/en/latest/index.html

License

Copyright (c) 2024 - Joseph Hale. All Rights Reserved.

httpmock by Joseph Hale is licensed under the terms of the Mozilla
Public License, v 2.0, which are available at https://mozilla.org/MPL/2.0/.

You can download the source code for httpmock for free from
https://github.com/thehale/httpmock.
What does the MPL-2.0 license allow/require?

TL;DR

You can use files from this project in both open source and proprietary applications, provided you include the above attribution. However, if you modify any code in this project, or copy blocks of it into your own code, you must publicly share the resulting files (note, not your whole program) under the MPL-2.0. The best way to do this is via a Pull Request back into this project.

If you have any other questions, you may also find Mozilla's official FAQ for the MPL-2.0 license insightful.

If you dislike this license, you can contact me about negotiating a paid contract with different terms.

Disclaimer: This TL;DR is just a summary. All legal questions regarding usage of this project must be handled according to the official terms specified in the LICENSE file.

Why the MPL-2.0 license?

I believe that an open-source software license should ensure that code can be used everywhere.

Strict copyleft licenses, like the GPL family of licenses, fail to fulfill that vision because they only permit code to be used in other GPL-licensed projects. Permissive licenses, like the MIT and Apache licenses, allow code to be used everywhere but fail to prevent proprietary or GPL-licensed projects from limiting access to any improvements they make.

In contrast, the MPL-2.0 license allows code to be used in any software project, while ensuring that any improvements remain available for everyone.

Metadata

Release files for httpmock 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for httpmock 0.1.0
File Size Uploaded Provenance Actions
httpmock-0.1.0.tar.gz 8.4 kB Without provenance Details for httpmock-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for httpmock 0.1.0
File Interpreter ABI Platform Actions
httpmock-0.1.0-py3-none-any.whl Python 3 none any Details for httpmock-0.1.0-py3-none-any.whl

Total release size: 17.9 kB

Release files / httpmock-0.1.0.tar.gz

Download URL httpmock-0.1.0.tar.gz
Size 8.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b00b6e95aebd09f0fdb022cd734f9d5a81e64530bd245dfc1e3913e042c6bcb0
BLAKE2b-256 checksum
How to use checksums
bc34faeb2bdd5a3f8e091b19e8cd0dd0442a2d250a164713175dcacc879346b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.10.2 Linux/6.5.0-1021-azure

Release files / httpmock-0.1.0-py3-none-any.whl

Download URL httpmock-0.1.0-py3-none-any.whl
Size 9.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c4ee148d7fe7a8aa223b1676aa7620928f3834f1c663d4cb4a7a77bcb5e8d05f
BLAKE2b-256 checksum
How to use checksums
6a42f24c5517bd5416da703e5b960045b4730540e81715a2884879178781d8a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.10.2 Linux/6.5.0-1021-azure

Security for httpmock 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page