Skip to main content

Build Status PyPI

wiremock-mock

Serve WireMock stubs with HTTPX2, responses or respx.

Requires Python 3.12+.

Installation

uv pip install wiremock-mock

Or with pip:

pip install wiremock-mock

Usage

requests with responses

"""Use WireMock stubs with requests and responses."""

from http import HTTPStatus
from typing import Any

import requests
import responses

from wiremock_mock import add_wiremock_to_responses

stubs: dict[str, Any] = {
    "mappings": [
        {
            "request": {"method": "GET", "urlPath": "/v1/pages"},
            "response": {
                "status": 200,
                "jsonBody": {"object": "list", "results": []},
            },
        },
    ],
}
with responses.RequestsMock(assert_all_requests_are_fired=False) as m:
    add_wiremock_to_responses(
        mock_obj=m, stubs=stubs, base_url="http://notion-mock.test"
    )
    response = requests.get(url="http://notion-mock.test/v1/pages", timeout=1)
    assert response.status_code == HTTPStatus.OK  # noqa: S101

The standard responses decorator workflow is also supported by passing responses.mock while @responses.activate is active.

httpx with respx

"""Use WireMock stubs with httpx and respx."""

from http import HTTPStatus
from typing import Any

import httpx
import respx

from wiremock_mock import add_wiremock_to_respx

stubs: dict[str, Any] = {
    "mappings": [
        {
            "request": {"method": "GET", "urlPath": "/v1/pages"},
            "response": {
                "status": 200,
                "jsonBody": {"object": "list", "results": []},
            },
        },
    ],
}
with respx.mock(
    base_url="http://notion-mock.test", assert_all_called=False
) as m:
    add_wiremock_to_respx(
        mock_obj=m, stubs=stubs, base_url="http://notion-mock.test"
    )
    response = httpx.get(url="http://notion-mock.test/v1/pages")
    assert response.status_code == HTTPStatus.OK  # noqa: S101

HTTPX2 with a native mock transport

"""Use WireMock stubs with HTTPX2."""

from http import HTTPStatus
from typing import Any

import httpx2

from wiremock_mock import create_httpx2_transport

stubs: dict[str, Any] = {
    "mappings": [
        {
            "request": {"method": "GET", "urlPath": "/v1/pages"},
            "response": {
                "status": 200,
                "jsonBody": {"object": "list", "results": []},
            },
        },
    ],
}
transport = create_httpx2_transport(
    stubs=stubs, base_url="http://notion-mock.test"
)
with httpx2.Client(transport=transport) as client:
    response = client.get(url="http://notion-mock.test/v1/pages")
assert response.status_code == HTTPStatus.OK  # noqa: S101

These integrations let you use existing WireMock stub files (e.g. from the WireMock Admin API import format) without running WireMock in Docker. HTTP traffic is mocked through responses for requests clients, respx for httpx clients, or a native mock transport for httpx2 clients. To load stubs from a JSON file, use json.loads(path.read_text()).

Use cases

  • Use existing WireMock stub files without running WireMock in Docker

  • Test against external APIs (e.g. Notion) without network access

  • Reuse stubs exported from WireMock Admin API or recorded mappings

  • Run tests in CI without Docker/socket dependencies

Supported stub features

  • Request matching: method, urlPath (exact), urlPathPattern (regex)

  • Query parameters: queryParameters with equalTo

  • Request body: bodyPatterns with equalToJson (honouring ignoreArrayOrder and ignoreExtraElements), contains and equalTo. This lets two requests to the same method and URL return different responses based on their bodies.

  • Response: status, statusMessage, single- or multi-value headers, jsonBody, body, base64Body

statusMessage is supported by the respx and HTTPX2 integrations; responses does not provide a custom reason-phrase hook.

Full documentation

See the full documentation for more information including how to contribute.

Metadata

Release files for wiremock-mock 2026.9.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wiremock-mock 2026.9.7
File Size Uploaded
wiremock_mock-2026.9.7.tar.gz 135.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for wiremock-mock 2026.9.7
File Interpreter ABI Platform
wiremock_mock-2026.9.7-py3-none-any.whl Python 3 none any Details

Total release size: 145.1 kB

Release files / wiremock_mock-2026.9.7.tar.gz

Download URL wiremock_mock-2026.9.7.tar.gz
Size 135.1 kB
Tags Source
SHA-256 checksum
How to use checksums
22428a369aa4d0b635e5ea18af6fabd27646d370dd847daaa890aca75c328cfb
BLAKE2b-256 checksum
How to use checksums
37d503667ee816387762d4b9490c4f389a6a85227ebb6d39d8fa33ffae95b593
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.

Transparency log

Release files / wiremock_mock-2026.9.7-py3-none-any.whl

Download URL wiremock_mock-2026.9.7-py3-none-any.whl
Size 10.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
356485c36e34c59a3695025669d6bb40d63874a066d4aea4c623963757b7eef9
BLAKE2b-256 checksum
How to use checksums
1abfadf3b8a4f31208434380344c61af292ec2c0e8ee4ca963aae9870c481187
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

2026.9.7 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page