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.15+. 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.16.2.tar.gz
(19.9 kB
view hashes)
Built Distribution
respx-0.16.2-py2.py3-none-any.whl
(25.5 kB
view hashes)
Close
Hashes for respx-0.16.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7707ebe90d96c7ff821d4b2d7ece88a0d17e9da0593fb8fb8c6b226d0732f2a8 |
|
MD5 | a47e6109de91db3768346e45a30b4748 |
|
BLAKE2b-256 | 1a3ba00adad97f454749153698d79d64fb67d2c37cdd1f0650aa33df681ad25e |