diff --git a/tests/keyboard_test.py b/tests/keyboard_test.py index 5cdaf12..1a507c5 100644 --- a/tests/keyboard_test.py +++ b/tests/keyboard_test.py @@ -74,7 +74,14 @@ class KeyboardTest: is_pressed = e[1] self.pins[key_pos].value = is_pressed self.do_main_loop() - self.keyboard._main_loop() + + # wait up to 10s for delayed actions to resolve, if there are any + timeout = time.time_ns() + 10 * 1_000_000_000 + while timeout > time.time_ns(): + self.do_main_loop() + if not self.keyboard._timeouts and not self.keyboard._resume_buffer: + break + assert timeout > time.time_ns(), 'infinite loop detected' matching = True for i in range(max(len(hid_reports), len(assert_reports))):