tests: Rename uasyncio to asyncio.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This commit is contained in:
Jim Mussared 2023-06-08 16:01:38 +10:00 committed by Damien George
parent 2fbc08c462
commit 6027c41c8f
81 changed files with 136 additions and 244 deletions

View File

@ -1,11 +1,8 @@
# Test that tasks return their value correctly to the caller # Test that tasks return their value correctly to the caller
try: try:
import uasyncio as asyncio
except ImportError:
try:
import asyncio import asyncio
except ImportError: except ImportError:
print("SKIP") print("SKIP")
raise SystemExit raise SystemExit

View File

@ -1,9 +1,6 @@
try: try:
import uasyncio as asyncio
except ImportError:
try:
import asyncio import asyncio
except ImportError: except ImportError:
print("SKIP") print("SKIP")
raise SystemExit raise SystemExit

View File

@ -1,9 +1,6 @@
try: try:
import uasyncio as asyncio
except ImportError:
try:
import asyncio import asyncio
except ImportError: except ImportError:
print("SKIP") print("SKIP")
raise SystemExit raise SystemExit

View File

@ -2,11 +2,8 @@
# That tasks which continuously cancel each other don't take over the scheduler # That tasks which continuously cancel each other don't take over the scheduler
try: try:
import uasyncio as asyncio
except ImportError:
try:
import asyncio import asyncio
except ImportError: except ImportError:
print("SKIP") print("SKIP")
raise SystemExit raise SystemExit

View File

@ -2,11 +2,8 @@
# That tasks which keeps being cancelled by multiple other tasks gets a chance to run # That tasks which keeps being cancelled by multiple other tasks gets a chance to run
try: try:
import uasyncio as asyncio
except ImportError:
try:
import asyncio import asyncio
except ImportError: except ImportError:
print("SKIP") print("SKIP")
raise SystemExit raise SystemExit

View File

@ -1,11 +1,8 @@
# Test a task cancelling itself (currently unsupported) # Test a task cancelling itself (currently unsupported)
try: try:
import uasyncio as asyncio
except ImportError:
try:
import asyncio import asyncio
except ImportError: except ImportError:
print("SKIP") print("SKIP")
raise SystemExit raise SystemExit

View File

@ -1,11 +1,8 @@
# Test cancelling a task # Test cancelling a task
try: try:
import uasyncio as asyncio
except ImportError:
try:
import asyncio import asyncio
except ImportError: except ImportError:
print("SKIP") print("SKIP")
raise SystemExit raise SystemExit

View File

@ -1,11 +1,8 @@
# Test cancelling a task that is waiting on a task that just finishes. # Test cancelling a task that is waiting on a task that just finishes.
try: try:
import uasyncio as asyncio
except ImportError:
try:
import asyncio import asyncio
except ImportError: except ImportError:
print("SKIP") print("SKIP")
raise SystemExit raise SystemExit

View File

@ -1,11 +1,8 @@
# Test current_task() function # Test current_task() function
try: try:
import uasyncio as asyncio
except ImportError:
try:
import asyncio import asyncio
except ImportError: except ImportError:
print("SKIP") print("SKIP")
raise SystemExit raise SystemExit

View File

@ -1,11 +1,8 @@
# Test Event class # Test Event class
try: try:
import uasyncio as asyncio
except ImportError:
try:
import asyncio import asyncio
except ImportError: except ImportError:
print("SKIP") print("SKIP")
raise SystemExit raise SystemExit

View File

@ -2,11 +2,8 @@
# That tasks which continuously wait on events don't take over the scheduler # That tasks which continuously wait on events don't take over the scheduler
try: try:
import uasyncio as asyncio
except ImportError:
try:
import asyncio import asyncio
except ImportError: except ImportError:
print("SKIP") print("SKIP")
raise SystemExit raise SystemExit

View File

@ -1,11 +1,8 @@
# Test general exception handling # Test general exception handling
try: try:
import uasyncio as asyncio
except ImportError:
try:
import asyncio import asyncio
except ImportError: except ImportError:
print("SKIP") print("SKIP")
raise SystemExit raise SystemExit

View File

@ -1,11 +1,8 @@
# Test fairness of scheduler # Test fairness of scheduler
try: try:
import uasyncio as asyncio
except ImportError:
try:
import asyncio import asyncio
except ImportError: except ImportError:
print("SKIP") print("SKIP")
raise SystemExit raise SystemExit

View File

@ -1,11 +1,8 @@
# test uasyncio.gather() function # test asyncio.gather() function
try: try:
import uasyncio as asyncio
except ImportError:
try:
import asyncio import asyncio
except ImportError: except ImportError:
print("SKIP") print("SKIP")
raise SystemExit raise SystemExit

View File

@ -1,11 +1,8 @@
# Test uasyncio.gather() function, features that are not implemented. # Test asyncio.gather() function, features that are not implemented.
try: try:
import uasyncio as asyncio
except ImportError:
try:
import asyncio import asyncio
except ImportError: except ImportError:
print("SKIP") print("SKIP")
raise SystemExit raise SystemExit

View File

@ -1,11 +1,8 @@
# Test get_event_loop() # Test get_event_loop()
try: try:
import uasyncio as asyncio
except ImportError:
try:
import asyncio import asyncio
except ImportError: except ImportError:
print("SKIP") print("SKIP")
raise SystemExit raise SystemExit

View File

@ -1,6 +1,6 @@
# test that the following do not use the heap: # test that the following do not use the heap:
# - basic scheduling of tasks # - basic scheduling of tasks
# - uasyncio.sleep_ms # - asyncio.sleep_ms
# - StreamWriter.write, stream is blocked and data to write is a bytes object # - StreamWriter.write, stream is blocked and data to write is a bytes object
# - StreamWriter.write, when stream is not blocked # - StreamWriter.write, when stream is not blocked
@ -25,11 +25,8 @@ except RuntimeError:
raise SystemExit raise SystemExit
try: try:
import uasyncio as asyncio
except ImportError:
try:
import asyncio import asyncio
except ImportError: except ImportError:
print("SKIP") print("SKIP")
raise SystemExit raise SystemExit

View File

@ -1,11 +1,8 @@
# Test Lock class # Test Lock class
try: try:
import uasyncio as asyncio
except ImportError:
try:
import asyncio import asyncio
except ImportError: except ImportError:
print("SKIP") print("SKIP")
raise SystemExit raise SystemExit

View File

@ -1,11 +1,8 @@
# Test that locks work when cancelling multiple waiters on the lock # Test that locks work when cancelling multiple waiters on the lock
try: try:
import uasyncio as asyncio
except ImportError:
try:
import asyncio import asyncio
except ImportError: except ImportError:
print("SKIP") print("SKIP")
raise SystemExit raise SystemExit

View File

@ -1,11 +1,8 @@
# Test Loop.stop() to stop the event loop # Test Loop.stop() to stop the event loop
try: try:
import uasyncio as asyncio
except ImportError:
try:
import asyncio import asyncio
except ImportError: except ImportError:
print("SKIP") print("SKIP")
raise SystemExit raise SystemExit

View File

@ -3,7 +3,7 @@
# - wait_for_ms # - wait_for_ms
try: try:
import time, uasyncio import time, asyncio
except ImportError: except ImportError:
print("SKIP") print("SKIP")
raise SystemExit raise SystemExit
@ -11,7 +11,7 @@ except ImportError:
async def task(id, t): async def task(id, t):
print("task start", id) print("task start", id)
await uasyncio.sleep_ms(t) await asyncio.sleep_ms(t)
print("task end", id) print("task end", id)
return id * 2 return id * 2
@ -19,25 +19,25 @@ async def task(id, t):
async def main(): async def main():
# Simple sleep_ms # Simple sleep_ms
t0 = time.ticks_ms() t0 = time.ticks_ms()
await uasyncio.sleep_ms(1) await asyncio.sleep_ms(1)
print(time.ticks_diff(time.ticks_ms(), t0) < 100) print(time.ticks_diff(time.ticks_ms(), t0) < 100)
try: try:
# Sleep 1ms beyond maximum allowed sleep value # Sleep 1ms beyond maximum allowed sleep value
await uasyncio.sleep_ms(time.ticks_add(0, -1) // 2 + 1) await asyncio.sleep_ms(time.ticks_add(0, -1) // 2 + 1)
except OverflowError: except OverflowError:
print("OverflowError") print("OverflowError")
# When task finished before the timeout # When task finished before the timeout
print(await uasyncio.wait_for_ms(task(1, 5), 50)) print(await asyncio.wait_for_ms(task(1, 5), 50))
# When timeout passes and task is cancelled # When timeout passes and task is cancelled
try: try:
print(await uasyncio.wait_for_ms(task(2, 50), 5)) print(await asyncio.wait_for_ms(task(2, 50), 5))
except uasyncio.TimeoutError: except asyncio.TimeoutError:
print("timeout") print("timeout")
print("finish") print("finish")
uasyncio.run(main()) asyncio.run(main())

View File

@ -1,11 +1,8 @@
# Test Loop.new_event_loop() # Test Loop.new_event_loop()
try: try:
import uasyncio as asyncio
except ImportError:
try:
import asyncio import asyncio
except ImportError: except ImportError:
print("SKIP") print("SKIP")
raise SystemExit raise SystemExit

View File

@ -1,11 +1,8 @@
# Test that tasks return their value correctly to the caller # Test that tasks return their value correctly to the caller
try: try:
import uasyncio as asyncio
except ImportError:
try:
import asyncio import asyncio
except ImportError: except ImportError:
print("SKIP") print("SKIP")
raise SystemExit raise SystemExit

View File

@ -1,11 +1,8 @@
# Test the Task.done() method # Test the Task.done() method
try: try:
import uasyncio as asyncio
except ImportError:
try:
import asyncio import asyncio
except ImportError: except ImportError:
print("SKIP") print("SKIP")
raise SystemExit raise SystemExit

View File

@ -1,7 +1,7 @@
# Test Event class # Test Event class
try: try:
import uasyncio as asyncio import asyncio
except ImportError: except ImportError:
print("SKIP") print("SKIP")
raise SystemExit raise SystemExit

View File

@ -1,11 +1,8 @@
# Test asyncio.wait_for # Test asyncio.wait_for
try: try:
import uasyncio as asyncio
except ImportError:
try:
import asyncio import asyncio
except ImportError: except ImportError:
print("SKIP") print("SKIP")
raise SystemExit raise SystemExit

View File

@ -1,11 +1,8 @@
# Test asyncio.wait_for, with forwarding cancellation # Test asyncio.wait_for, with forwarding cancellation
try: try:
import uasyncio as asyncio
except ImportError:
try:
import asyncio import asyncio
except ImportError: except ImportError:
print("SKIP") print("SKIP")
raise SystemExit raise SystemExit

View File

@ -1,11 +1,8 @@
# Test waiting on a task # Test waiting on a task
try: try:
import uasyncio as asyncio
except ImportError:
try:
import asyncio import asyncio
except ImportError: except ImportError:
print("SKIP") print("SKIP")
raise SystemExit raise SystemExit

View File

@ -102,7 +102,7 @@ def instance0():
# Client # Client
def instance1(): def instance1():
try: try:
import uasyncio as asyncio import asyncio
from aioespnow import AIOESPNow from aioespnow import AIOESPNow
except ImportError: except ImportError:
print("SKIP") print("SKIP")

View File

@ -58,7 +58,7 @@ async def echo_server(e):
# Server # Server
def instance0(): def instance0():
try: try:
import uasyncio as asyncio import asyncio
from aioespnow import AIOESPNow from aioespnow import AIOESPNow
except ImportError: except ImportError:
print("SKIP") print("SKIP")

View File

@ -1,11 +1,8 @@
# Test TCP server with client issuing TCP RST part way through read # Test TCP server with client issuing TCP RST part way through read
try: try:
import uasyncio as asyncio
except ImportError:
try:
import asyncio import asyncio
except ImportError: except ImportError:
print("SKIP") print("SKIP")
raise SystemExit raise SystemExit

View File

@ -1,11 +1,8 @@
# Test uasyncio TCP stream closing then writing # Test asyncio TCP stream closing then writing
try: try:
import uasyncio as asyncio
except ImportError:
try:
import asyncio import asyncio
except ImportError: except ImportError:
print("SKIP") print("SKIP")
raise SystemExit raise SystemExit

View File

@ -1,11 +1,8 @@
# Test uasyncio stream read(-1) method using TCP server/client # Test asyncio stream read(-1) method using TCP server/client
try: try:
import uasyncio as asyncio
except ImportError:
try:
import asyncio import asyncio
except ImportError: except ImportError:
print("SKIP") print("SKIP")
raise SystemExit raise SystemExit

View File

@ -1,11 +1,8 @@
# Test uasyncio stream readexactly() method using TCP server/client # Test asyncio stream readexactly() method using TCP server/client
try: try:
import uasyncio as asyncio
except ImportError:
try:
import asyncio import asyncio
except ImportError: except ImportError:
print("SKIP") print("SKIP")
raise SystemExit raise SystemExit

View File

@ -1,11 +1,8 @@
# Test uasyncio stream readinto() method using TCP server/client # Test asyncio stream readinto() method using TCP server/client
try: try:
import uasyncio as asyncio
except ImportError:
try:
import asyncio import asyncio
except ImportError: except ImportError:
print("SKIP") print("SKIP")
raise SystemExit raise SystemExit

View File

@ -1,11 +1,8 @@
# Test uasyncio TCP server and client using start_server() and open_connection() # Test asyncio TCP server and client using start_server() and open_connection()
try: try:
import uasyncio as asyncio
except ImportError:
try:
import asyncio import asyncio
except ImportError: except ImportError:
print("SKIP") print("SKIP")
raise SystemExit raise SystemExit

View File

@ -1,11 +1,8 @@
# Test basic behaviour of uasyncio.start_server() # Test basic behaviour of asyncio.start_server()
try: try:
import uasyncio as asyncio
except ImportError:
try:
import asyncio import asyncio
except ImportError: except ImportError:
print("SKIP") print("SKIP")
raise SystemExit raise SystemExit

View File

@ -1,11 +1,8 @@
# Test cancelling a task waiting on stream IO # Test cancelling a task waiting on stream IO
try: try:
import uasyncio as asyncio
except ImportError:
try:
import asyncio import asyncio
except ImportError: except ImportError:
print("SKIP") print("SKIP")
raise SystemExit raise SystemExit

View File

@ -1,11 +1,8 @@
# Test simple HTTP request with uasyncio.open_connection() # Test simple HTTP request with asyncio.open_connection()
try: try:
import uasyncio as asyncio
except ImportError:
try:
import asyncio import asyncio
except ImportError: except ImportError:
print("SKIP") print("SKIP")
raise SystemExit raise SystemExit

View File

@ -1,11 +1,8 @@
# Test uasyncio.open_connection() and stream readline() # Test asyncio.open_connection() and stream readline()
try: try:
import uasyncio as asyncio
except ImportError:
try:
import asyncio import asyncio
except ImportError: except ImportError:
print("SKIP") print("SKIP")
raise SystemExit raise SystemExit

View File

@ -624,10 +624,10 @@ def run_tests(pyb, tests, args, result_dir, num_threads=1):
skip_tests.add("basics/sys_tracebacklimit.py") # requires traceback info skip_tests.add("basics/sys_tracebacklimit.py") # requires traceback info
skip_tests.add("basics/try_finally_return2.py") # requires raise_varargs skip_tests.add("basics/try_finally_return2.py") # requires raise_varargs
skip_tests.add("basics/unboundlocal.py") # requires checking for unbound local skip_tests.add("basics/unboundlocal.py") # requires checking for unbound local
skip_tests.add("extmod/uasyncio_event.py") # unknown issue skip_tests.add("extmod/asyncio_event.py") # unknown issue
skip_tests.add("extmod/uasyncio_lock.py") # requires async with skip_tests.add("extmod/asyncio_lock.py") # requires async with
skip_tests.add("extmod/uasyncio_micropython.py") # unknown issue skip_tests.add("extmod/asyncio_micropython.py") # unknown issue
skip_tests.add("extmod/uasyncio_wait_for.py") # unknown issue skip_tests.add("extmod/asyncio_wait_for.py") # unknown issue
skip_tests.add("misc/features.py") # requires raise_varargs skip_tests.add("misc/features.py") # requires raise_varargs
skip_tests.add( skip_tests.add(
"misc/print_exception.py" "misc/print_exception.py"
@ -672,7 +672,7 @@ def run_tests(pyb, tests, args, result_dir, num_threads=1):
is_bytearray = test_name.startswith("bytearray") or test_name.endswith("_bytearray") is_bytearray = test_name.startswith("bytearray") or test_name.endswith("_bytearray")
is_set_type = test_name.startswith(("set_", "frozenset")) or test_name.endswith("_set") is_set_type = test_name.startswith(("set_", "frozenset")) or test_name.endswith("_set")
is_slice = test_name.find("slice") != -1 or test_name in misc_slice_tests is_slice = test_name.find("slice") != -1 or test_name in misc_slice_tests
is_async = test_name.startswith(("async_", "uasyncio_")) is_async = test_name.startswith(("async_", "asyncio_"))
is_const = test_name.startswith("const") is_const = test_name.startswith("const")
is_io_module = test_name.startswith("io_") is_io_module = test_name.startswith("io_")
is_fstring = test_name.startswith("string_fstring") is_fstring = test_name.startswith("string_fstring")

View File

@ -50,7 +50,7 @@ RuntimeError:
ame__ ame__
port port
builtins micropython _thread _uasyncio builtins micropython _asyncio _thread
array binascii btree cexample array binascii btree cexample
cmath collections cppexample cryptolib cmath collections cppexample cryptolib
errno example_package ffi errno example_package ffi