API Reference

Package for serving WireMock stubs with Python HTTP mocking libraries.

wiremock_mock.add_wiremock_to_responses(*, mock_obj: RequestsMock, stubs: dict[str, Any], base_url: str) None

Add mock routes from WireMock stubs to a responses mock.

Request matching and response fields are the same as for add_wiremock_to_respx(), except that custom statusMessage values are not supported by responses.

Parameters:
  • mock_obj – The responses RequestsMock to add routes to.

  • stubs – WireMock stubs dict with mappings array (e.g. from json.loads(path.read_text())).

  • base_url – Base URL for all routes.

wiremock_mock.add_wiremock_to_respx(*, mock_obj: MockRouter | Router, stubs: dict[str, Any], base_url: str) None

Add mock routes from WireMock stubs to a respx mock/router.

Supports request matching by: - method - urlPath (exact) or urlPathPattern (regex) - queryParameters with equalTo - bodyPatterns (equalToJson, contains, equalTo)

equalToJson supports the ignoreArrayOrder and ignoreExtraElements options. Multiple bodyPatterns on a single stub must all match, letting two requests to the same method and URL return different responses based on their bodies.

Response supports status, statusMessage, headers, jsonBody, body and base64Body from each stub.

Parameters:
  • mock_obj – The respx MockRouter or Router to add routes to.

  • stubs – WireMock stubs dict with mappings array (e.g. from json.loads(path.read_text())).

  • base_url – Base URL for all routes. Must match respx.mock().