MCPcopy
hub / github.com/openai/openai-python / test_default_headers_option

Method test_default_headers_option

tests/test_client.py:419–446  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

417 )
418
419 def test_default_headers_option(self) -> None:
420 test_client = OpenAI(
421 base_url=base_url,
422 api_key=api_key,
423 admin_api_key=admin_api_key,
424 _strict_response_validation=True,
425 default_headers={"X-Foo": "bar"},
426 )
427 request = test_client._build_request(FinalRequestOptions(method="get", url="/foo"))
428 assert request.headers.get("x-foo") == "bar"
429 assert request.headers.get("x-stainless-lang") == "python"
430
431 test_client2 = OpenAI(
432 base_url=base_url,
433 api_key=api_key,
434 admin_api_key=admin_api_key,
435 _strict_response_validation=True,
436 default_headers={
437 "X-Foo": "stainless",
438 "X-Stainless-Lang": "my-overriding-header",
439 },
440 )
441 request = test_client2._build_request(FinalRequestOptions(method="get", url="/foo"))
442 assert request.headers.get("x-foo") == "stainless"
443 assert request.headers.get("x-stainless-lang") == "my-overriding-header"
444
445 test_client.close()
446 test_client2.close()
447
448 def test_validate_headers(self) -> None:
449 client = OpenAI(

Callers

nothing calls this directly

Calls 5

OpenAIClass · 0.90
FinalRequestOptionsClass · 0.90
_build_requestMethod · 0.45
getMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected