Skip to content

Commit a561bf6

Browse files
committed
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>
1 parent 4ef36d7 commit a561bf6

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

tests/extmod/asyncio_as_uasyncio.py

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,33 @@
11
try:
22
import uasyncio
3-
import asyncio
43
except ImportError:
54
print("SKIP")
65
raise SystemExit
76

8-
x = set(dir(uasyncio))
9-
y = set(dir(asyncio)) - set(["event", "lock", "stream", "funcs"])
107

11-
print(x - y)
12-
print(y - x)
8+
# Sample of public symbols we expect to see from `asyncio`. Verify they're all
9+
# available on `uasyncio`.
10+
expected = [
11+
"CancelledError",
12+
"create_task",
13+
"current_task",
14+
"Event",
15+
"gather",
16+
"get_event_loop",
17+
"Lock",
18+
"Loop",
19+
"open_connection",
20+
"run",
21+
"run_until_complete",
22+
"sleep",
23+
"sleep_ms",
24+
"start_server",
25+
"StreamReader",
26+
"StreamWriter",
27+
"Task",
28+
"ThreadSafeFlag",
29+
"wait_for",
30+
]
31+
32+
for e in expected:
33+
getattr(uasyncio, e)
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +0,0 @@
1-
set()
2-
set()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy