Skip to content

Commit ffe5106

Browse files
Correct test
1 parent 019ed9d commit ffe5106

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

Lib/test/test_asyncio/test_tasks.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,20 +1009,15 @@ def gen():
10091009
self.assertEqual(res, "ok")
10101010

10111011
def test_wait_for_cancellation_race_condition(self):
1012-
def gen():
1013-
yield 0.1
1014-
yield 0.1
1015-
yield 0.1
1016-
yield 0.1
1012+
async def inner():
1013+
await asyncio.wait_for(asyncio.sleep(1), timeout=2)
1014+
return 1
10171015

1018-
loop = self.new_test_loop(gen)
1016+
async def main():
1017+
result = await asyncio.wait_for(inner(), timeout=1)
1018+
assert result == 1
10191019

1020-
fut = self.new_future(loop)
1021-
loop.call_later(0.1, fut.set_result, "ok")
1022-
task = loop.create_task(asyncio.wait_for(fut, timeout=1))
1023-
loop.call_later(0.1, task.cancel)
1024-
res = loop.run_until_complete(task)
1025-
self.assertEqual(res, "ok")
1020+
asyncio.run(main())
10261021

10271022
def test_wait_for_waits_for_task_cancellation(self):
10281023
loop = asyncio.new_event_loop()

0 commit comments

Comments
 (0)