File tree Expand file tree Collapse file tree 1 file changed +13
-10
lines changed
Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Original file line number Diff line number Diff line change 1- import asyncio
21import socket
32import threading
43import time
5- from collections .abc import Generator
64from dataclasses import dataclass , field
75
86import pytest
119import swerex .server
1210from swerex .runtime .abstract import (
1311 BashAction ,
14- CloseBashSessionRequest ,
1512 Command ,
1613 CreateBashSessionRequest ,
1714)
@@ -55,17 +52,23 @@ def run_server():
5552
5653
5754@pytest .fixture
58- def remote_runtime (remote_server : RemoteServer ) -> Generator [RemoteRuntime , None ]:
55+ async def remote_runtime (remote_server : RemoteServer ):
56+ """Async fixture for RemoteRuntime that properly handles cleanup."""
5957 r = RemoteRuntime (port = remote_server .port , auth_token = TEST_API_KEY )
60- yield r
61- asyncio .run (r .close ())
58+ try :
59+ yield r
60+ finally :
61+ await r .close ()
6262
6363
6464@pytest .fixture
65- def runtime_with_default_session (remote_runtime : RemoteRuntime ) -> Generator [RemoteRuntime , None ]:
66- asyncio .run (remote_runtime .create_session (CreateBashSessionRequest ()))
67- yield remote_runtime
68- asyncio .run (remote_runtime .close_session (CloseBashSessionRequest ()))
65+ async def runtime_with_default_session (remote_runtime : RemoteRuntime ):
66+ """Async fixture that creates a default session and cleans it up properly."""
67+ await remote_runtime .create_session (CreateBashSessionRequest ())
68+ try :
69+ yield remote_runtime
70+ finally :
71+ await remote_runtime .close ()
6972
7073
7174class _Action (BashAction ):
You can’t perform that action at this time.
0 commit comments