Need help with respx?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

lundberg
170 Stars 16 Forks BSD 3-Clause "New" or "Revised" License 347 Commits 8 Opened issues

Description

Mock HTTPX with awesome request patterns and response side effects 🦋

Services available

!
?

Need anything else?

Contributors list

# 8,530
Python
Django
python3
cleaner
259 commits
# 62,678
apache
Django
XML
python-...
1 commit
# 219,060
Shell
Rust
forex
algorit...
1 commit
# 257,086
Shell
godaddy
aliyun
GraphQL
1 commit
# 6,786
mac
pypi
nanogen...
prose
1 commit

RESPX

RESPX - Mock HTTPX with awesome request patterns and response side effects.


codecov PyPi Version Python Versions

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.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.