2525from subprocess import Popen , TimeoutExpired
2626from types import SimpleNamespace
2727
28- import sys
29- if sys .version_info >= (3 , 11 ):
30- from asyncio import timeout
31- else :
32- from async_timeout import timeout
33-
3428from cylc .flow import CYLC_LOG
3529from cylc .flow .exceptions import CylcError
3630from cylc .flow .id import Tokens
@@ -145,6 +139,7 @@ async def test_start_services(
145139 return_value = Mock (
146140 spec = Popen ,
147141 wait = Mock (return_value = 0 ),
142+ communicate = lambda : ('out' , 'err' ),
148143 )
149144 )
150145 monkeypatch .setattr ('cylc.uiserver.resolvers.Popen' , mock_popen )
@@ -260,7 +255,11 @@ def wait(timeout):
260255
261256 mock_popen = Mock (
262257 spec = Popen ,
263- return_value = Mock (spec = Popen , wait = wait )
258+ return_value = Mock (
259+ spec = Popen ,
260+ wait = wait ,
261+ communicate = lambda : ('out' , 'err' ),
262+ ),
264263 )
265264 monkeypatch .setattr ('cylc.uiserver.resolvers.Popen' , mock_popen )
266265
@@ -270,9 +269,9 @@ def wait(timeout):
270269 {},
271270 log = Mock (),
272271 )
273- assert ret == [
274- False , "Command 'cylc play wflow1' timed out after 120 seconds"
275- ]
272+ assert ret == (
273+ False , "Command 'cylc play wflow1' timed out after 120 seconds\n err "
274+ )
276275
277276
278277@pytest .fixture
@@ -331,7 +330,7 @@ async def test_cat_log(workflow_run_dir, app, fast_sleep):
331330
332331 # note - timeout tests that the cat-log process is being stopped correctly
333332 first_response = None
334- async with timeout (20 ):
333+ async with asyncio . timeout (20 ):
335334 ret = services .cat_log (workflow , app , info )
336335 actual = ''
337336 is_first = True
@@ -380,7 +379,7 @@ async def test_cat_log_timeout(workflow_run_dir, app, fast_sleep):
380379
381380 ret = services .cat_log (workflow , app , info )
382381 responses = []
383- async with timeout (5 ):
382+ async with asyncio . timeout (5 ):
384383 async for response in ret :
385384 responses .append (response )
386385 await asyncio .sleep (0 )
0 commit comments