Check the stopped timer once stop returns, not after a wait

This commit is contained in:
2026-11-19 04:44:37 +01:00
parent 78dd557057
commit 708347382b
+2 -1
View File
@@ -152,8 +152,9 @@ class Timer(unittest.TestCase):
def test_a_timer_stopped_before_its_delay_has_passed_never_runs_the_action(self):
ran = threading.Event()
# stop returns once the timer's thread has ended, so the action cannot run later.
start_timer(0.2, ran.set)()
self.assertFalse(ran.wait(0.5))
self.assertFalse(ran.is_set())
def test_stopping_a_timer_whose_action_runs_waits_for_the_action_to_end(self):
started, ended = threading.Event(), threading.Event()