Skip to content

Commit b6280b1

Browse files
authored
Improve PyPy test robustness (#1985)
* increase timeout for PyPy * remove duration arg
1 parent efa9f0d commit b6280b1

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

test/back2back_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Back2BackTestCase(unittest.TestCase):
3333
"""
3434

3535
BITRATE = 500000
36-
TIMEOUT = 0.1
36+
TIMEOUT = 1.0 if IS_PYPY else 0.1
3737

3838
INTERFACE_1 = "virtual"
3939
CHANNEL_1 = "virtual_channel_0"

test/simplecyclic_test.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55
"""
66

77
import gc
8+
import platform
89
import sys
910
import time
1011
import traceback
1112
import unittest
1213
from threading import Thread
1314
from time import sleep
14-
from typing import List
1515
from unittest.mock import MagicMock
1616

1717
import can
1818

19-
from .config import *
19+
from .config import IS_CI, IS_PYPY
2020
from .message_helper import ComparingMessagesTestCase
2121

2222

@@ -133,7 +133,7 @@ def test_stopping_perodic_tasks(self):
133133
data=[0, 1, 2, 3, 4, 5, 6, 7],
134134
)
135135
msg.arbitration_id = task_i
136-
task = bus.send_periodic(msg, 0.1, 1)
136+
task = bus.send_periodic(msg, period=0.1)
137137
tasks.append(task)
138138

139139
assert len(bus._periodic_tasks) == 10
@@ -261,7 +261,7 @@ def test_thread_based_cyclic_send_task(self):
261261
task.stop()
262262

263263
def test_modifier_callback(self) -> None:
264-
msg_list: List[can.Message] = []
264+
msg_list: list[can.Message] = []
265265

266266
def increment_first_byte(msg: can.Message) -> None:
267267
msg.data[0] = (msg.data[0] + 1) % 256
@@ -288,8 +288,8 @@ def increment_first_byte(msg: can.Message) -> None:
288288
self.assertEqual(b"\x07\x00\x00\x00\x00\x00\x00\x00", bytes(msg_list[6].data))
289289

290290
@staticmethod
291-
def join_threads(threads: List[Thread], timeout: float) -> None:
292-
stuck_threads: List[Thread] = []
291+
def join_threads(threads: list[Thread], timeout: float) -> None:
292+
stuck_threads: list[Thread] = []
293293
t0 = time.perf_counter()
294294
for thread in threads:
295295
time_left = timeout - (time.perf_counter() - t0)

0 commit comments

Comments
 (0)