Skip to content

Latest commit

 

History

History
52 lines (35 loc) · 1.85 KB

README.md

File metadata and controls

52 lines (35 loc) · 1.85 KB

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.