15
15
def mock_client_post (client , post_mock ):
16
16
# huggingface-hub==0.28.0 deprecates the `post` method
17
17
# 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
20
22
21
23
22
24
@pytest .mark .parametrize (
@@ -33,7 +35,8 @@ def test_nonstreaming_chat_completion(
33
35
)
34
36
events = capture_events ()
35
37
36
- client = InferenceClient ()
38
+ client = InferenceClient (model = "https://" )
39
+
37
40
if details_arg :
38
41
post_mock = mock .Mock (
39
42
return_value = b"""[{
@@ -92,7 +95,7 @@ def test_streaming_chat_completion(
92
95
)
93
96
events = capture_events ()
94
97
95
- client = InferenceClient ()
98
+ client = InferenceClient (model = "https://" )
96
99
97
100
post_mock = mock .Mock (
98
101
return_value = [
@@ -141,7 +144,7 @@ def test_bad_chat_completion(sentry_init, capture_events):
141
144
sentry_init (integrations = [HuggingfaceHubIntegration ()], traces_sample_rate = 1.0 )
142
145
events = capture_events ()
143
146
144
- client = InferenceClient ()
147
+ client = InferenceClient (model = "https://" )
145
148
post_mock = mock .Mock (side_effect = OverloadedError ("The server is overloaded" ))
146
149
mock_client_post (client , post_mock )
147
150
@@ -159,7 +162,7 @@ def test_span_origin(sentry_init, capture_events):
159
162
)
160
163
events = capture_events ()
161
164
162
- client = InferenceClient ()
165
+ client = InferenceClient (model = "https://" )
163
166
post_mock = mock .Mock (
164
167
return_value = [
165
168
b"""data:{
0 commit comments