11"""Tests for centml.cli.shell -- CLI terminal access commands."""
22
3+ import asyncio
34import json
45import urllib .parse
56from unittest .mock import AsyncMock , MagicMock , patch
@@ -197,8 +198,7 @@ def test_multiple_revisions(self):
197198
198199
199200class TestExecSession :
200- @pytest .mark .asyncio
201- async def test_sends_resize_and_wrapped_command (self ):
201+ def test_sends_resize_and_wrapped_command (self ):
202202 from centml .cli .shell import _exec_session , _BEGIN_MARKER , _END_MARKER
203203
204204 ws = AsyncMock ()
@@ -213,7 +213,7 @@ async def test_sends_resize_and_wrapped_command(self):
213213 return_value = AsyncMock (__aenter__ = AsyncMock (return_value = ws ), __aexit__ = AsyncMock (return_value = False ))
214214 )
215215
216- exit_code = await _exec_session ("wss://test/ws" , "fake-token" , "ls -la" )
216+ exit_code = asyncio . run ( _exec_session ("wss://test/ws" , "fake-token" , "ls -la" ) )
217217
218218 assert exit_code == 0
219219 assert ws .send .call_count == 2
@@ -228,8 +228,7 @@ async def test_sends_resize_and_wrapped_command(self):
228228 assert _BEGIN_MARKER not in cmd_msg ["data" ]
229229 assert "CENTML_BEGIN" in cmd_msg ["data" ]
230230
231- @pytest .mark .asyncio
232- async def test_returns_nonzero_exit_code_from_marker (self ):
231+ def test_returns_nonzero_exit_code_from_marker (self ):
233232 from centml .cli .shell import _exec_session , _BEGIN_MARKER , _END_MARKER
234233
235234 ws = AsyncMock ()
@@ -241,12 +240,11 @@ async def test_returns_nonzero_exit_code_from_marker(self):
241240 return_value = AsyncMock (__aenter__ = AsyncMock (return_value = ws ), __aexit__ = AsyncMock (return_value = False ))
242241 )
243242
244- exit_code = await _exec_session ("wss://test/ws" , "fake-token" , "false" )
243+ exit_code = asyncio . run ( _exec_session ("wss://test/ws" , "fake-token" , "false" ) )
245244
246245 assert exit_code == 42
247246
248- @pytest .mark .asyncio
249- async def test_error_message_returns_one (self ):
247+ def test_error_message_returns_one (self ):
250248 from centml .cli .shell import _exec_session
251249
252250 ws = AsyncMock ()
@@ -258,12 +256,11 @@ async def test_error_message_returns_one(self):
258256 return_value = AsyncMock (__aenter__ = AsyncMock (return_value = ws ), __aexit__ = AsyncMock (return_value = False ))
259257 )
260258
261- exit_code = await _exec_session ("wss://test/ws" , "fake-token" , "bad" )
259+ exit_code = asyncio . run ( _exec_session ("wss://test/ws" , "fake-token" , "bad" ) )
262260
263261 assert exit_code == 1
264262
265- @pytest .mark .asyncio
266- async def test_filters_noise_before_marker (self ):
263+ def test_filters_noise_before_marker (self ):
267264 """Only output between BEGIN and END markers is written to stdout."""
268265 from centml .cli .shell import _exec_session , _BEGIN_MARKER , _END_MARKER
269266
@@ -283,7 +280,7 @@ async def test_filters_noise_before_marker(self):
283280 mock_sys .stdout .flush = MagicMock ()
284281 mock_sys .stderr .write = MagicMock ()
285282
286- exit_code = await _exec_session ("wss://test/ws" , "fake-token" , "echo test" )
283+ exit_code = asyncio . run ( _exec_session ("wss://test/ws" , "fake-token" , "echo test" ) )
287284
288285 assert exit_code == 0
289286 output = "" .join (captured )
@@ -297,8 +294,7 @@ async def test_filters_noise_before_marker(self):
297294
298295
299296class TestInteractiveSessionTerminalRestore :
300- @pytest .mark .asyncio
301- async def test_restores_terminal_on_exception (self ):
297+ def test_restores_terminal_on_exception (self ):
302298 from centml .cli .shell import _interactive_session
303299
304300 with patch ("centml.cli.shell.sys" ) as mock_sys , patch ("centml.cli.shell.termios" ) as mock_termios , patch (
@@ -322,7 +318,7 @@ async def test_restores_terminal_on_exception(self):
322318 )
323319
324320 with pytest .raises (ConnectionRefusedError ):
325- await _interactive_session ("wss://test/ws" , "fake-token" )
321+ asyncio . run ( _interactive_session ("wss://test/ws" , "fake-token" ) )
326322
327323 mock_termios .tcsetattr .assert_called ()
328324 restore_call = mock_termios .tcsetattr .call_args
0 commit comments