2323from subprocess import Popen , TimeoutExpired
2424from types import SimpleNamespace
2525
26- import sys
27- if sys .version_info >= (3 , 11 ):
28- from asyncio import timeout
29- else :
30- from async_timeout import timeout
31-
3226from cylc .flow import CYLC_LOG
3327from cylc .flow .exceptions import CylcError
3428from cylc .flow .id import Tokens
@@ -139,6 +133,7 @@ async def test_play(
139133 return_value = Mock (
140134 spec = Popen ,
141135 wait = Mock (return_value = 0 ),
136+ communicate = lambda : ('out' , 'err' ),
142137 )
143138 )
144139 monkeypatch .setattr ('cylc.uiserver.resolvers.Popen' , mock_popen )
@@ -247,7 +242,11 @@ def wait(timeout):
247242
248243 mock_popen = Mock (
249244 spec = Popen ,
250- return_value = Mock (spec = Popen , wait = wait )
245+ return_value = Mock (
246+ spec = Popen ,
247+ wait = wait ,
248+ communicate = lambda : ('out' , 'err' ),
249+ ),
251250 )
252251 monkeypatch .setattr ('cylc.uiserver.resolvers.Popen' , mock_popen )
253252
@@ -257,9 +256,9 @@ def wait(timeout):
257256 {},
258257 log = Mock (),
259258 )
260- assert ret == [
261- False , "Command 'cylc play wflow1' timed out after 120 seconds"
262- ]
259+ assert ret == (
260+ False , "Command 'cylc play wflow1' timed out after 120 seconds\n err "
261+ )
263262
264263
265264@pytest .fixture
@@ -318,7 +317,7 @@ async def test_cat_log(workflow_run_dir, app, fast_sleep):
318317
319318 # note - timeout tests that the cat-log process is being stopped correctly
320319 first_response = None
321- async with timeout (20 ):
320+ async with asyncio . timeout (20 ):
322321 ret = services .cat_log (workflow , app , info )
323322 actual = ''
324323 is_first = True
@@ -367,7 +366,7 @@ async def test_cat_log_timeout(workflow_run_dir, app, fast_sleep):
367366
368367 ret = services .cat_log (workflow , app , info )
369368 responses = []
370- async with timeout (5 ):
369+ async with asyncio . timeout (5 ):
371370 async for response in ret :
372371 responses .append (response )
373372 await asyncio .sleep (0 )
0 commit comments