@@ -180,6 +180,7 @@ def mock_tool_invoke(
180
180
181
181
# --- Tests for General ToolboxSyncClient Functionality ---
182
182
183
+
183
184
def test_sync_load_tool_success (aioresponses , test_tool_str_schema , sync_client ):
184
185
TOOL_NAME = "test_tool_sync_1"
185
186
mock_tool_load (aioresponses , TOOL_NAME , test_tool_str_schema )
@@ -273,11 +274,15 @@ class TestSyncClientLifecycle:
273
274
274
275
def test_sync_client_creation_in_isolated_env (self , sync_client ):
275
276
"""Tests that a client is initialized correctly by the sync_client fixture."""
276
- assert sync_client ._ToolboxSyncClient__loop is not None , "Loop should be created"
277
+ assert (
278
+ sync_client ._ToolboxSyncClient__loop is not None
279
+ ), "Loop should be created"
277
280
assert (
278
281
sync_client ._ToolboxSyncClient__thread is not None
279
282
), "Thread should be created"
280
- assert sync_client ._ToolboxSyncClient__thread .is_alive (), "Thread should be running"
283
+ assert (
284
+ sync_client ._ToolboxSyncClient__thread .is_alive ()
285
+ ), "Thread should be running"
281
286
assert isinstance (
282
287
sync_client ._ToolboxSyncClient__async_client , ToolboxClient
283
288
), "Async client should be ToolboxClient instance"
@@ -325,9 +330,7 @@ def test_sync_client_context_manager(self, aioresponses, tool_schema_minimal):
325
330
ToolboxSyncClient , "close" , wraps = ToolboxSyncClient .close , autospec = True
326
331
) as mock_close_method_exc :
327
332
with pytest .raises (ValueError , match = "Test exception" ):
328
- with ToolboxSyncClient (
329
- TEST_BASE_URL
330
- ) as client_exc :
333
+ with ToolboxSyncClient (TEST_BASE_URL ) as client_exc :
331
334
raise ValueError ("Test exception" )
332
335
mock_close_method_exc .assert_called_once ()
333
336
@@ -351,26 +354,32 @@ def test_load_tool_raises_if_loop_or_thread_none(self):
351
354
352
355
# Manually break the class's loop to trigger the error condition in load_tool
353
356
ToolboxSyncClient ._ToolboxSyncClient__loop = None
354
- with pytest .raises (ValueError , match = "Background loop or thread cannot be None." ):
357
+ with pytest .raises (
358
+ ValueError , match = "Background loop or thread cannot be None."
359
+ ):
355
360
client .load_tool ("any_tool_should_fail" )
356
361
ToolboxSyncClient ._ToolboxSyncClient__loop = (
357
362
original_class_loop # Restore for next check
358
363
)
359
364
360
365
ToolboxSyncClient ._ToolboxSyncClient__thread = None
361
- with pytest .raises (ValueError , match = "Background loop or thread cannot be None." ):
366
+ with pytest .raises (
367
+ ValueError , match = "Background loop or thread cannot be None."
368
+ ):
362
369
client .load_toolset ("any_toolset_should_fail" )
363
370
ToolboxSyncClient ._ToolboxSyncClient__thread = original_class_thread # Restore
364
371
365
- client .close () # Clean up manually created client
372
+ client .close () # Clean up manually created client
366
373
# sync_client_environment will handle the final cleanup of original_class_loop/thread.
367
374
368
375
369
376
class TestSyncClientHeaders :
370
377
"""Additive tests for client header functionality specific to ToolboxSyncClient if any,
371
378
or counterparts to async client header tests."""
372
379
373
- def test_sync_add_headers_success (self , aioresponses , test_tool_str_schema , sync_client ):
380
+ def test_sync_add_headers_success (
381
+ self , aioresponses , test_tool_str_schema , sync_client
382
+ ):
374
383
tool_name = "tool_after_add_headers_sync"
375
384
manifest = ManifestSchema (
376
385
serverVersion = "0.0.0" , tools = {tool_name : test_tool_str_schema }
0 commit comments