From 196a8653a24abe26d474899570398426877c7563 Mon Sep 17 00:00:00 2001 From: Damien George Date: Fri, 26 Sep 2025 15:19:48 +1000 Subject: [PATCH] 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 --- tests/extmod/time_res.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/extmod/time_res.py b/tests/extmod/time_res.py index 548bef1f17..ef20050b91 100644 --- a/tests/extmod/time_res.py +++ b/tests/extmod/time_res.py @@ -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)