MCPcopy Create free account
hub / github.com/openai/openai-python / test_async_response_parse_custom_model

Function test_async_response_parse_custom_model

tests/test_response.py:146–158  ·  view source on GitHub ↗
(async_client: AsyncOpenAI)

Source from the content-addressed store, hash-verified

144
145@pytest.mark.asyncio
146async def test_async_response_parse_custom_model(async_client: AsyncOpenAI) -> None:
147 response = AsyncAPIResponse(
148 raw=httpx.Response(200, content=json.dumps({"foo": "hello!", "bar": 2})),
149 client=async_client,
150 stream=False,
151 stream_cls=None,
152 cast_to=str,
153 options=FinalRequestOptions.construct(method="get", url="/foo"),
154 )
155
156 obj = await response.parse(to=CustomModel)
157 assert obj.foo == "hello!"
158 assert obj.bar == 2
159
160
161def test_response_basemodel_request_id(client: OpenAI) -> None:

Callers

nothing calls this directly

Calls 3

parseMethod · 0.95
AsyncAPIResponseClass · 0.90
constructMethod · 0.45

Tested by

no test coverage detected