Class ExpectationToPythonSerializer
java.lang.Object
org.mockserver.serialization.code.ExpectationToPythonSerializer
Generates copy-paste-ready Python expectation code for the MockServer Python
client (
mockserver).
The Python client accepts an expectation as a dict via
Expectation.from_dict(...) passed to client.upsert(...). To
keep the embedded payload byte-identical to format=JSON (and avoid
fragile JSON-token-to-Python-literal translation of true/false/
null), each expectation's JSON is embedded as a triple-quoted string
parsed at runtime with json.loads(...).
Example output for a single expectation:
import json
from mockserver import MockServerClient, Expectation
client = MockServerClient("localhost", 1080)
client.upsert(Expectation.from_dict(json.loads(JSON)))
One client.upsert(...) call is emitted per expectation.- Author:
- jamesdbloom
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
ExpectationToPythonSerializer
-
-
Method Details
-
serialize
-