1515def mock_client_post (client , post_mock ):
1616 # huggingface-hub==0.28.0 deprecates the `post` method
1717 # so patch `_inner_post` instead
18- client .post = post_mock
19- client ._inner_post = post_mock
18+ if hasattr (client , "post" ):
19+ client .post = post_mock
20+ if hasattr (client , "_inner_post" ):
21+ client ._inner_post = post_mock
2022
2123
2224@pytest .mark .parametrize (
@@ -33,7 +35,8 @@ def test_nonstreaming_chat_completion(
3335 )
3436 events = capture_events ()
3537
36- client = InferenceClient ()
38+ client = InferenceClient (model = "https://" )
39+
3740 if details_arg :
3841 post_mock = mock .Mock (
3942 return_value = b"""[{
@@ -92,7 +95,7 @@ def test_streaming_chat_completion(
9295 )
9396 events = capture_events ()
9497
95- client = InferenceClient ()
98+ client = InferenceClient (model = "https://" )
9699
97100 post_mock = mock .Mock (
98101 return_value = [
@@ -141,7 +144,7 @@ def test_bad_chat_completion(sentry_init, capture_events):
141144 sentry_init (integrations = [HuggingfaceHubIntegration ()], traces_sample_rate = 1.0 )
142145 events = capture_events ()
143146
144- client = InferenceClient ()
147+ client = InferenceClient (model = "https://" )
145148 post_mock = mock .Mock (side_effect = OverloadedError ("The server is overloaded" ))
146149 mock_client_post (client , post_mock )
147150
@@ -159,7 +162,7 @@ def test_span_origin(sentry_init, capture_events):
159162 )
160163 events = capture_events ()
161164
162- client = InferenceClient ()
165+ client = InferenceClient (model = "https://" )
163166 post_mock = mock .Mock (
164167 return_value = [
165168 b"""data:{
0 commit comments