mirror of
https://github.com/micropython/micropython.git
synced 2026-01-06 20:20:14 +01:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user