kopia lustrzana https://github.com/micropython/micropython
tests/extmod/asyncio_as_uasyncio.py: Fix qstr order dependency.
This test depends on the order in which qstrs are stored in ROM, which affects the order in which `dir()` will probe the object to see what it supports. Because of the lazy-loading in asyncio/__init__.py, if it tries to do e.g. `wait_for_ms` before `funcs` then it will import funcs, making `funcs` later succeed. But in the other way around, `funcs` will initially not be found. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>pull/12678/head
rodzic
1a017511d0
commit
78f4f30cb1
|
@ -1,12 +1,33 @@
|
||||||
try:
|
try:
|
||||||
import uasyncio
|
import uasyncio
|
||||||
import asyncio
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
x = set(dir(uasyncio))
|
|
||||||
y = set(dir(asyncio)) - set(["event", "lock", "stream", "funcs"])
|
|
||||||
|
|
||||||
print(x - y)
|
# Sample of public symbols we expect to see from `asyncio`. Verify they're all
|
||||||
print(y - x)
|
# available on `uasyncio`.
|
||||||
|
expected = [
|
||||||
|
"CancelledError",
|
||||||
|
"create_task",
|
||||||
|
"current_task",
|
||||||
|
"Event",
|
||||||
|
"gather",
|
||||||
|
"get_event_loop",
|
||||||
|
"Lock",
|
||||||
|
"Loop",
|
||||||
|
"open_connection",
|
||||||
|
"run",
|
||||||
|
"run_until_complete",
|
||||||
|
"sleep",
|
||||||
|
"sleep_ms",
|
||||||
|
"start_server",
|
||||||
|
"StreamReader",
|
||||||
|
"StreamWriter",
|
||||||
|
"Task",
|
||||||
|
"ThreadSafeFlag",
|
||||||
|
"wait_for",
|
||||||
|
]
|
||||||
|
|
||||||
|
for e in expected:
|
||||||
|
getattr(uasyncio, e)
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
set()
|
|
||||||
set()
|
|
Ładowanie…
Reference in New Issue