Skip to main content

Build Status PyPI

wiremock-mock

Serve WireMock stubs with 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

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 or respx for httpx 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 integration; responses does not provide a custom reason-phrase hook.

Full documentation

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

Download files

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

Source Distribution

wiremock_mock-2026.8.16.tar.gz (131.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wiremock_mock-2026.8.16-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file wiremock_mock-2026.8.16.tar.gz.

File metadata

  • Download URL: wiremock_mock-2026.8.16.tar.gz
  • Upload date:
  • Size: 131.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for wiremock_mock-2026.8.16.tar.gz
Algorithm Hash digest
SHA256 4d00eb7ba2acaa32cd59369dbb323d45195551c9dabb22afd920771d4d20ed66
MD5 2ab5c5505fbe36a43de95e06a83d377e
BLAKE2b-256 6c4eff95c3003dc8c6355beada97e9afa778390653073bb20743aeb6969024fd

See more details on using hashes here.

Provenance

The following attestation bundles were made for wiremock_mock-2026.8.16.tar.gz:

Publisher: release.yml on adamtheturtle/wiremock-mock

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file wiremock_mock-2026.8.16-py3-none-any.whl.

File metadata

File hashes

Hashes for wiremock_mock-2026.8.16-py3-none-any.whl
Algorithm Hash digest
SHA256 f2ac8652f8e582f3f02394b8a08c303a2e1c5fd06c3d7282a89fc78ebeaa524d
MD5 fd0f35663d3c3151d9dbad61d97f2510
BLAKE2b-256 dc81d20068a536c22bfb85c24b214ef6425d59906a0b5fa459cfbcc78146d568

See more details on using hashes here.

Provenance

The following attestation bundles were made for wiremock_mock-2026.8.16-py3-none-any.whl:

Publisher: release.yml on adamtheturtle/wiremock-mock

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page