@@ -292,6 +292,16 @@ def test_http_client_timeout_option(self) -> None:
292
292
timeout = httpx .Timeout (** request .extensions ["timeout" ]) # type: ignore
293
293
assert timeout == DEFAULT_TIMEOUT # our default
294
294
295
+ async def test_invalid_http_client (self ) -> None :
296
+ with pytest .raises (TypeError , match = "Invalid `http_client` arg" ):
297
+ async with httpx .AsyncClient () as http_client :
298
+ OpenAI (
299
+ base_url = base_url ,
300
+ api_key = api_key ,
301
+ _strict_response_validation = True ,
302
+ http_client = cast (Any , http_client ),
303
+ )
304
+
295
305
def test_default_headers_option (self ) -> None :
296
306
client = OpenAI (
297
307
base_url = base_url , api_key = api_key , _strict_response_validation = True , default_headers = {"X-Foo" : "bar" }
@@ -994,6 +1004,16 @@ async def test_http_client_timeout_option(self) -> None:
994
1004
timeout = httpx .Timeout (** request .extensions ["timeout" ]) # type: ignore
995
1005
assert timeout == DEFAULT_TIMEOUT # our default
996
1006
1007
+ def test_invalid_http_client (self ) -> None :
1008
+ with pytest .raises (TypeError , match = "Invalid `http_client` arg" ):
1009
+ with httpx .Client () as http_client :
1010
+ AsyncOpenAI (
1011
+ base_url = base_url ,
1012
+ api_key = api_key ,
1013
+ _strict_response_validation = True ,
1014
+ http_client = cast (Any , http_client ),
1015
+ )
1016
+
997
1017
def test_default_headers_option (self ) -> None :
998
1018
client = AsyncOpenAI (
999
1019
base_url = base_url , api_key = api_key , _strict_response_validation = True , default_headers = {"X-Foo" : "bar" }
0 commit comments