pytest-httpx2 1.0.0


pip install pytest-httpx2

  Latest version

Released: May 20, 2026


Meta
Author: Jonas Lundberg
Requires Python: >=3.10

Classifiers

Programming Language
  • Python :: 3

Operating System
  • OS Independent

pytest-httpx2

A pytest plugin for mocking out httpx2 using respx.

import httpx2

def test_foobar(httpx2_mock: respx.Router) -> None:
    httpx2_mock.post("https://example.com/foobar").respond(201)
    response = httpx2.post("https://example.com/foobar")
    assert response.status_code == 201

Configure using marker

import pytest
import httpx2

@pytest.mark.httpx2(base_url="https://example.com")
def test_hamspam(httpx2_mock: respx.Router) -> None:
    httpx2_mock.get("/hamspam").respond(json={"id": 1337})
    response = httpx2.get("https://example.com/hamspam")
    assert response.status_code == 200
    assert response.json() == {"id": 1337}

See respx documentation for more configuration options and api.

Wheel compatibility matrix

Platform Python 3
any

Files in release

Extras: None
Dependencies:
respx