diff options
| author | Damien George <damien@micropython.org> | 2025-09-26 15:19:48 +1000 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2025-10-20 12:59:44 +1100 |
| commit | 196a8653a24abe26d474899570398426877c7563 (patch) | |
| tree | 9ba56c7abe07831ad34984d74880e6648d98b5f5 /tests/extmod/time_res.py | |
| parent | 3b46c0018a0656bd98f0320efb00c11c268b44d3 (diff) | |
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>
Diffstat (limited to 'tests/extmod/time_res.py')
| -rw-r--r-- | tests/extmod/time_res.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/tests/extmod/time_res.py b/tests/extmod/time_res.py index 548bef1f1..ef20050b9 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) |
