@@ -300,6 +300,16 @@ def test_http_client_timeout_option(self) -> None:
300
300
timeout = httpx .Timeout (** request .extensions ["timeout" ]) # type: ignore
301
301
assert timeout == DEFAULT_TIMEOUT # our default
302
302
303
+ async def test_invalid_http_client (self ) -> None :
304
+ with pytest .raises (TypeError , match = "Invalid `http_client` arg" ):
305
+ async with httpx .AsyncClient () as http_client :
306
+ Anthropic (
307
+ base_url = base_url ,
308
+ api_key = api_key ,
309
+ _strict_response_validation = True ,
310
+ http_client = cast (Any , http_client ),
311
+ )
312
+
303
313
def test_default_headers_option (self ) -> None :
304
314
client = Anthropic (
305
315
base_url = base_url , api_key = api_key , _strict_response_validation = True , default_headers = {"X-Foo" : "bar" }
@@ -1103,6 +1113,16 @@ async def test_http_client_timeout_option(self) -> None:
1103
1113
timeout = httpx .Timeout (** request .extensions ["timeout" ]) # type: ignore
1104
1114
assert timeout == DEFAULT_TIMEOUT # our default
1105
1115
1116
+ def test_invalid_http_client (self ) -> None :
1117
+ with pytest .raises (TypeError , match = "Invalid `http_client` arg" ):
1118
+ with httpx .Client () as http_client :
1119
+ AsyncAnthropic (
1120
+ base_url = base_url ,
1121
+ api_key = api_key ,
1122
+ _strict_response_validation = True ,
1123
+ http_client = cast (Any , http_client ),
1124
+ )
1125
+
1106
1126
def test_default_headers_option (self ) -> None :
1107
1127
client = AsyncAnthropic (
1108
1128
base_url = base_url , api_key = api_key , _strict_response_validation = True , default_headers = {"X-Foo" : "bar" }
0 commit comments