micropython/tests/extmod/uasyncio_current_task.py
Jim Mussared 7ed99544e4 extmod/uasyncio: Add asyncio.current_task().
Matches CPython behavior.

Fixes #6686
2021-02-13 15:11:17 +11:00

26 lines
440 B
Python

# Test current_task() function
try:
import uasyncio as asyncio
except ImportError:
try:
import asyncio
except ImportError:
print("SKIP")
raise SystemExit
async def task(result):
result[0] = asyncio.current_task()
async def main():
result = [None]
t = asyncio.create_task(task(result))
await asyncio.sleep(0)
await asyncio.sleep(0)
print(t is result[0])
asyncio.run(main())