From 7ed99544e4cc1c09bd5abf9f54869c3122fa033b Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Fri, 12 Feb 2021 14:11:18 +1100 Subject: extmod/uasyncio: Add asyncio.current_task(). Matches CPython behavior. Fixes #6686 --- tests/extmod/uasyncio_current_task.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tests/extmod/uasyncio_current_task.py (limited to 'tests/extmod/uasyncio_current_task.py') diff --git a/tests/extmod/uasyncio_current_task.py b/tests/extmod/uasyncio_current_task.py new file mode 100644 index 000000000..3165a2cf1 --- /dev/null +++ b/tests/extmod/uasyncio_current_task.py @@ -0,0 +1,25 @@ +# 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()) -- cgit v1.2.3