MCPcopy Create free account
hub / github.com/anthropics/anthropic-sdk-python / test_serialize_data

Function test_serialize_data

tests/test_prepare.py:345–358  ·  view source on GitHub ↗
(sync: bool)

Source from the content-addressed store, hash-verified

343
344@pytest.mark.parametrize("sync", [True, False], ids=["sync", "async"])
345async def test_serialize_data(sync: bool) -> None:
346 def body() -> object:
347 return {
348 "nested": MappingProxyType({"keep": (1, 2), "drop": omit}),
349 "when": datetime(2024, 1, 2, 3, 4, 5, tzinfo=timezone.utc),
350 }
351
352 if sync:
353 serialized = serialize_data(body(), location="body")
354 assert serialized == openapi_dumps_str(prepare_request_data(body(), location="body"))
355 else:
356 serialized = await async_serialize_data(body(), location="body")
357 assert serialized == openapi_dumps_str(await async_prepare_request_data(body(), location="body"))
358 assert serialized == '{"nested":{"keep":[1,2]},"when":"2024-01-02T03:04:05+00:00"}'
359
360
361@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 6

serialize_dataFunction · 0.90
openapi_dumps_strFunction · 0.90
prepare_request_dataFunction · 0.90
async_serialize_dataFunction · 0.90
bodyFunction · 0.70

Tested by

no test coverage detected