Skip to content


codecov PyPi Version Python Versions

A utility for mocking out the Python HTTPX and HTTP Core libraries.


Start by mocking out HTTPX and/or HTTP Core, using respx.mock, and then add desired request patterns to mock your responses.

import httpx
import respx

def test_something():
    request ="", status_code=201)
    response ="")
    assert request.called
    assert response.status_code == 201


The QuickStart section covers the basics. Continue reading in detail on how Mocking HTTPX is done, or head over to the Developer Interface for a complete guide on how to mock your responses.


You can use RESPX not only to mock out HTTPX, but to actually mock responses for any library using HTTP Core.


Install with pip:

$ pip install respx

Requires Python 3.6+ and HTTPX 0.14.0+. See Changelog for older HTTPX compatibility.