22
33import pytest
44
5- from copilot import CopilotClient , PermissionHandler
5+ from copilot import CopilotClient , PermissionHandler , StopError
66
77from .testharness import CLI_PATH
88
@@ -20,8 +20,7 @@ async def test_should_start_and_connect_to_server_using_stdio(self):
2020 assert pong .message == "pong: test message"
2121 assert pong .timestamp >= 0
2222
23- errors = await client .stop ()
24- assert len (errors ) == 0
23+ await client .stop ()
2524 assert client .get_state () == "disconnected"
2625 finally :
2726 await client .force_stop ()
@@ -38,14 +37,13 @@ async def test_should_start_and_connect_to_server_using_tcp(self):
3837 assert pong .message == "pong: test message"
3938 assert pong .timestamp >= 0
4039
41- errors = await client .stop ()
42- assert len (errors ) == 0
40+ await client .stop ()
4341 assert client .get_state () == "disconnected"
4442 finally :
4543 await client .force_stop ()
4644
4745 @pytest .mark .asyncio
48- async def test_should_return_errors_on_failed_cleanup (self ):
46+ async def test_should_raise_exception_group_on_failed_cleanup (self ):
4947 import asyncio
5048
5149 client = CopilotClient ({"cli_path" : CLI_PATH })
@@ -59,9 +57,11 @@ async def test_should_return_errors_on_failed_cleanup(self):
5957 process .kill ()
6058 await asyncio .sleep (0.1 )
6159
62- errors = await client .stop ()
63- assert len (errors ) > 0
64- assert "Failed to destroy session" in errors [0 ].message
60+ with pytest .raises (ExceptionGroup ) as exc_info :
61+ await client .stop ()
62+ assert len (exc_info .value .exceptions ) > 0
63+ assert isinstance (exc_info .value .exceptions [0 ], StopError )
64+ assert "Failed to destroy session" in exc_info .value .exceptions [0 ].message
6565 finally :
6666 await client .force_stop ()
6767
0 commit comments