@@ -188,7 +188,9 @@ async def test_ws_client_happy_request_and_response(
188
188
initialized_ws_client_session : ClientSession ,
189
189
) -> None :
190
190
"""Test a successful request and response via WebSocket"""
191
- result = await initialized_ws_client_session .read_resource ("foobar://example" )
191
+ result = await initialized_ws_client_session .read_resource (
192
+ AnyUrl ("foobar://example" )
193
+ )
192
194
assert isinstance (result , ReadResourceResult )
193
195
assert isinstance (result .contents , list )
194
196
assert len (result .contents ) > 0
@@ -202,7 +204,7 @@ async def test_ws_client_exception_handling(
202
204
) -> None :
203
205
"""Test exception handling in WebSocket communication"""
204
206
with pytest .raises (McpError ) as exc_info :
205
- await initialized_ws_client_session .read_resource ("unknown://example" )
207
+ await initialized_ws_client_session .read_resource (AnyUrl ( "unknown://example" ) )
206
208
assert exc_info .value .error .code == 404
207
209
208
210
@@ -214,11 +216,13 @@ async def test_ws_client_timeout(
214
216
# Set a very short timeout to trigger a timeout exception
215
217
with pytest .raises (TimeoutError ):
216
218
with anyio .fail_after (0.1 ): # 100ms timeout
217
- await initialized_ws_client_session .read_resource ("slow://example" )
219
+ await initialized_ws_client_session .read_resource (AnyUrl ( "slow://example" ) )
218
220
219
221
# Now test that we can still use the session after a timeout
220
222
with anyio .fail_after (5 ): # Longer timeout to allow completion
221
- result = await initialized_ws_client_session .read_resource ("foobar://example" )
223
+ result = await initialized_ws_client_session .read_resource (
224
+ AnyUrl ("foobar://example" )
225
+ )
222
226
assert isinstance (result , ReadResourceResult )
223
227
assert isinstance (result .contents , list )
224
228
assert len (result .contents ) > 0
0 commit comments