tests/extmod/time_res.py: Properly skip functions not in time module.

If `time.time` doesn't exist, it tries to use `globals()['time']` which is
the time module itself, and that causes the test to fail.  Instead it
should just skip `time.time`.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George
2025-09-26 15:19:48 +10:00
parent 3b46c0018a
commit 196a8653a2

View File

@@ -37,9 +37,12 @@ def test():
time.sleep_ms(100)
for func_name, _ in EXPECTED_MAP:
try:
time_func = getattr(time, func_name, None) or globals()[func_name]
if func_name.endswith("_time"):
time_func = globals()[func_name]
else:
time_func = getattr(time, func_name)
now = time_func() # may raise AttributeError
except (KeyError, AttributeError):
except AttributeError:
continue
try:
results_map[func_name].add(now)