(self)
| 336 | assert request.headers.get("x-stainless-lang") == "my-overriding-header" |
| 337 | |
| 338 | def test_validate_headers(self) -> None: |
| 339 | client = Anthropic(base_url=base_url, api_key=api_key, _strict_response_validation=True) |
| 340 | request = client._build_request(FinalRequestOptions(method="get", url="/foo")) |
| 341 | assert request.headers.get("X-Api-Key") == api_key |
| 342 | |
| 343 | with update_env(**{"ANTHROPIC_API_KEY": Omit()}): |
| 344 | client2 = Anthropic(base_url=base_url, api_key=None, _strict_response_validation=True) |
| 345 | |
| 346 | with pytest.raises( |
| 347 | TypeError, |
| 348 | match="Could not resolve authentication method. Expected either api_key or auth_token to be set. Or for one of the `X-Api-Key` or `Authorization` headers to be explicitly omitted", |
| 349 | ): |
| 350 | client2._build_request(FinalRequestOptions(method="get", url="/foo")) |
| 351 | |
| 352 | request2 = client2._build_request(FinalRequestOptions(method="get", url="/foo", headers={"X-Api-Key": Omit()})) |
| 353 | assert request2.headers.get("X-Api-Key") is None |
| 354 | |
| 355 | def test_default_query_option(self) -> None: |
| 356 | client = Anthropic( |
nothing calls this directly
no test coverage detected