Skip to main content

pytest fixture for HTTPX

Project description

pytest fixture for HTTPX

pypi version Build status Coverage Code style: black Number of tests Number of downloads

This module is still under development and cannot be considered stable.

Use pytest_httpx.httpx_mock pytest fixture to mock httpx requests.

Add responses

import httpx
from pytest_httpx import httpx_mock, HTTPXMock


def test_something(httpx_mock: HTTPXMock):
    httpx_mock.add_response("http://test_url")

    response = httpx.get("http://test_url")

If all responses are not sent back during test execution, the test case will fail.

Check sent requests

import httpx
from pytest_httpx import httpx_mock, HTTPXMock


def test_something(httpx_mock: HTTPXMock):
    httpx_mock.add_response("http://test_url")

    response = httpx.get("http://test_url")

    # requests are in httpx_mock.requests

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_httpx-0.0.1.tar.gz (3.5 kB view hashes)

Uploaded Source

Built Distribution

pytest_httpx-0.0.1-py3-none-any.whl (4.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page