@@ -127,17 +127,21 @@ async def test_run_tool_no_auth(self, toolbox):
127127 tool = await toolbox .aload_tool (
128128 "get-row-by-id-auth" ,
129129 )
130- with pytest .raises (ClientResponseError , match = "401, message='Unauthorized'" ):
131- await tool .acall (id = "2" )
130+ response = await tool .acall (id = "2" )
131+ assert response .is_error == True
132+ assert "401, message='Unauthorized'" in response .content
133+ assert isinstance (response .raw_output , str )
132134
133135 async def test_run_tool_wrong_auth (self , toolbox , auth_token2 ):
134136 """Tests running a tool with incorrect auth."""
135137 tool = await toolbox .aload_tool (
136138 "get-row-by-id-auth" ,
137139 )
138140 auth_tool = tool .add_auth_token ("my-test-auth" , lambda : auth_token2 )
139- with pytest .raises (ClientResponseError , match = "401, message='Unauthorized'" ):
140- await auth_tool .acall (id = "2" )
141+ response = await auth_tool .acall (id = "2" )
142+ assert response .is_error == True
143+ assert "401, message='Unauthorized'" in response .content
144+ assert isinstance (response .raw_output , str )
141145
142146 async def test_run_tool_auth (self , toolbox , auth_token1 ):
143147 """Tests running a tool with correct auth."""
@@ -173,8 +177,10 @@ async def test_run_tool_param_auth_no_field(self, toolbox, auth_token1):
173177 tool = await toolbox .aload_tool (
174178 "get-row-by-content-auth" , auth_tokens = {"my-test-auth" : lambda : auth_token1 }
175179 )
176- with pytest .raises (ClientResponseError , match = "400, message='Bad Request'" ):
177- await tool .acall ()
180+ response = await tool .acall ()
181+ assert response .is_error == True
182+ assert "400, message='Bad Request'" in response .content
183+ assert isinstance (response .raw_output , str )
178184
179185
180186@pytest .mark .usefixtures ("toolbox_server" )
@@ -261,18 +267,21 @@ def test_run_tool_no_auth(self, toolbox):
261267 tool = toolbox .load_tool (
262268 "get-row-by-id-auth" ,
263269 )
264- with pytest .raises (ClientResponseError , match = "401, message='Unauthorized'" ):
265- tool .call (id = "2" )
270+ response = tool .call (id = "2" )
271+ assert response .is_error == True
272+ assert "401, message='Unauthorized'" in response .content
273+ assert isinstance (response .raw_output , str )
266274
267275 def test_run_tool_wrong_auth (self , toolbox , auth_token2 ):
268276 """Tests running a tool with incorrect auth."""
269277 tool = toolbox .load_tool (
270278 "get-row-by-id-auth" ,
271279 )
272280 auth_tool = tool .add_auth_token ("my-test-auth" , lambda : auth_token2 )
273-
274- with pytest .raises (ClientResponseError , match = "401, message='Unauthorized'" ):
275- auth_tool .call (id = "2" )
281+ response = auth_tool .call (id = "2" )
282+ assert response .is_error == True
283+ assert "401, message='Unauthorized'" in response .content
284+ assert isinstance (response .raw_output , str )
276285
277286 def test_run_tool_auth (self , toolbox , auth_token1 ):
278287 """Tests running a tool with correct auth."""
@@ -308,5 +317,7 @@ def test_run_tool_param_auth_no_field(self, toolbox, auth_token1):
308317 tool = toolbox .load_tool (
309318 "get-row-by-content-auth" , auth_tokens = {"my-test-auth" : lambda : auth_token1 }
310319 )
311- with pytest .raises (ClientResponseError , match = "400, message='Bad Request'" ):
312- tool .call (id = "2" )
320+ response = tool .call ()
321+ assert response .is_error == True
322+ assert "400, message='Bad Request'" in response .content
323+ assert isinstance (response .raw_output , str )
0 commit comments