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

Function test_response_parse_pep604_union

tests/test_response.py:323–335  ·  view source on GitHub ↗
(client: Anthropic)

Source from the content-addressed store, hash-verified

321
322
323def test_response_parse_pep604_union(client: Anthropic) -> None:
324 response = APIResponse(
325 raw=httpx2.Response(200, content=json.dumps({"a": "hello!"}), headers={"Content-Type": "application/json"}),
326 client=client,
327 stream=False,
328 stream_cls=None,
329 cast_to=str,
330 options=FinalRequestOptions.construct(method="get", url="/foo"),
331 )
332
333 obj = response.parse(to=cast(Any, CustomModel | OtherModel))
334 assert isinstance(obj, OtherModel)
335 assert obj.a == "hello!"
336
337
338@pytest.mark.asyncio

Callers

nothing calls this directly

Calls 3

parseMethod · 0.95
APIResponseClass · 0.90
constructMethod · 0.45

Tested by

no test coverage detected