diff --git a/test/back2back_test.py b/test/back2back_test.py index d5e6f6b89..3ff33012f 100644 --- a/test/back2back_test.py +++ b/test/back2back_test.py @@ -273,19 +273,22 @@ def test_sub_second_timestamp_resolution(self): self.bus2.recv(0) self.bus2.recv(0) - def test_perodic_tasks_do_not_exceed_duration(self): - duration, period = 2.0, 0.6 - messages = [] - - self.bus2.send_periodic(can.Message(), period, duration) - while True: - msg = self.bus1.recv(period + 0.1) - if msg is None: - break - messages.append(msg) - - delta_t = messages[-1].timestamp - messages[0].timestamp - assert delta_t <= duration + def test_send_periodic_duration(self): + """ + Verify that send_periodic only transmits for the specified duration. + + Regression test for #1713. + """ + for params in [(0.01, 0.003), (0.1, 0.011), (1, 0.4)]: + duration, period = params + messages = [] + + self.bus2.send_periodic(can.Message(), period, duration) + while (msg := self.bus1.recv(period * 1.25)) is not None: + messages.append(msg) + + delta_t = messages[-1].timestamp - messages[0].timestamp + assert delta_t <= duration @unittest.skipUnless(TEST_INTERFACE_SOCKETCAN, "skip testing of socketcan")