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

Method test_received_text_for_expected_json

tests/test_client.py:1055–1076  ·  view source on GitHub ↗
(self, respx_mock: MockRouter)

Source from the content-addressed store, hash-verified

1053
1054 @pytest.mark.respx(base_url=base_url)
1055 def test_received_text_for_expected_json(self, respx_mock: MockRouter) -> None:
1056 class Model(BaseModel):
1057 name: str
1058
1059 respx_mock.get("/foo").mock(return_value=httpx.Response(200, text="my-custom-format"))
1060
1061 strict_client = OpenAI(
1062 base_url=base_url, api_key=api_key, admin_api_key=admin_api_key, _strict_response_validation=True
1063 )
1064
1065 with pytest.raises(APIResponseValidationError):
1066 strict_client.get("/foo", cast_to=Model)
1067
1068 non_strict_client = OpenAI(
1069 base_url=base_url, api_key=api_key, admin_api_key=admin_api_key, _strict_response_validation=False
1070 )
1071
1072 response = non_strict_client.get("/foo", cast_to=Model)
1073 assert isinstance(response, str) # type: ignore[unreachable]
1074
1075 strict_client.close()
1076 non_strict_client.close()
1077
1078 @pytest.mark.parametrize(
1079 "remaining_retries,retry_after,timeout",

Callers

nothing calls this directly

Calls 3

OpenAIClass · 0.90
getMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected