A utility for mocking out the Python HTTPX and HTTP Core libraries.
Project description
RESPX - Mock HTTPX with awesome request patterns and response side effects.
Documentation
Full documentation is available at lundberg.github.io/respx
QuickStart
RESPX is a simple, yet powerful, utility for mocking out the HTTPX, and HTTP Core, libraries.
Start by patching HTTPX
, using respx.mock
, then add request routes to mock responses.
import httpx
import respx
from httpx import Response
@respx.mock
def test_example():
my_route = respx.get("https://example.org/").mock(return_value=Response(204))
response = httpx.get("https://example.org/")
assert my_route.called
assert response.status_code == 204
Read the User Guide for a complete walk-through.
Installation
Install with pip:
$ pip install respx
Requires Python 3.6+ and HTTPX 0.18+. See Changelog for older HTTPX compatibility.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
respx-0.17.0.tar.gz
(22.1 kB
view hashes)
Built Distribution
respx-0.17.0-py2.py3-none-any.whl
(27.5 kB
view hashes)
Close
Hashes for respx-0.17.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d8630774b447b5ecd7641c8592082fb13e77c97f2857abf732b7ce1b4f26587a |
|
MD5 | 30947ac6f4becf40bb90c5b7e336f47b |
|
BLAKE2b-256 | 0131ede965caa9b2c02a878cba6ee53742971924b87e8e6eb892e8b74218bd93 |