Skip to content

Commit 907e8f2

Browse files
alblascoTinche
authored andcommitted
FIX new test_cases on python 3.5 & 3.6
asyncio.create_task has been added in Python 3.7. The low-level asyncio.ensure_future() function can be used instead (works in all Python versions but is less readable). https://docs.python.org/3/library/asyncio-task.html#asyncio.create_task
1 parent 51d986c commit 907e8f2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tests/async_fixtures/test_async_fixtures_with_finalizer.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ async def port_afinalizer():
3232
await finalizer
3333
event_loop.run_until_complete(port_afinalizer())
3434

35-
worker = asyncio.create_task(asyncio.sleep(0.2))
35+
worker = asyncio.ensure_future(asyncio.sleep(0.2))
3636
request.addfinalizer(functools.partial(port_finalizer, worker))
3737
return True
3838

@@ -46,6 +46,6 @@ async def port_afinalizer():
4646
await finalizer
4747
asyncio.get_event_loop().run_until_complete(port_afinalizer())
4848

49-
worker = asyncio.create_task(asyncio.sleep(0.2))
49+
worker = asyncio.ensure_future(asyncio.sleep(0.2))
5050
request.addfinalizer(functools.partial(port_finalizer, worker))
5151
return True

0 commit comments

Comments
 (0)