Skip to content

Commit db52d39

Browse files
committed
add lazy tests and use old black formatter
1 parent e307da5 commit db52d39

3 files changed

Lines changed: 42 additions & 13 deletions

File tree

can/interfaces/vector/canlib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ def popup_vector_hw_configuration(wait_for_finish: int = 0) -> None:
589589

590590
@staticmethod
591591
def get_application_config(
592-
app_name: str, app_channel: int, bus_type: xldefine.XL_BusTypes,
592+
app_name: str, app_channel: int, bus_type: xldefine.XL_BusTypes
593593
) -> Tuple[xldefine.XL_HardwareType, int, int]:
594594
"""Retrieve information for an application in Vector Hardware Configuration.
595595

can/interfaces/vector/xldriver.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,18 @@ def check_status(result, function, arguments):
6363
xlGetApplConfig.restype = xlclass.XLstatus
6464
xlGetApplConfig.errcheck = check_status
6565

66+
xlSetApplConfig = _xlapi_dll.xlSetApplConfig
67+
xlSetApplConfig.argtypes = [
68+
ctypes.c_char_p,
69+
ctypes.c_uint,
70+
ctypes.c_uint,
71+
ctypes.c_uint,
72+
ctypes.c_uint,
73+
ctypes.c_uint,
74+
]
75+
xlSetApplConfig.restype = xlclass.XLstatus
76+
xlSetApplConfig.errcheck = check_status
77+
6678
xlGetChannelIndex = _xlapi_dll.xlGetChannelIndex
6779
xlGetChannelIndex.argtypes = [ctypes.c_int, ctypes.c_int, ctypes.c_int]
6880
xlGetChannelIndex.restype = ctypes.c_int
@@ -235,18 +247,6 @@ def check_status(result, function, arguments):
235247
xlPopupHwConfig.restype = xlclass.XLstatus
236248
xlPopupHwConfig.errcheck = check_status
237249

238-
xlSetApplConfig = _xlapi_dll.xlSetApplConfig
239-
xlSetApplConfig.argtypes = [
240-
ctypes.c_char_p,
241-
ctypes.c_uint,
242-
ctypes.c_uint,
243-
ctypes.c_uint,
244-
ctypes.c_uint,
245-
ctypes.c_uint,
246-
]
247-
xlSetApplConfig.restype = xlclass.XLstatus
248-
xlSetApplConfig.errcheck = check_status
249-
250250
xlSetTimerRate = _xlapi_dll.xlSetTimerRate
251251
xlSetTimerRate.argtypes = [xlclass.XLportHandle, ctypes.c_ulong]
252252
xlSetTimerRate.restype = xlclass.XLstatus

test/test_vector.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,35 @@ def test_popup_hw_cfg(self) -> None:
248248
assert isinstance(args[0], ctypes.c_char_p)
249249
assert isinstance(args[1], ctypes.c_uint)
250250

251+
def test_get_application_config(self) -> None:
252+
canlib.xldriver.xlGetApplConfig = Mock()
253+
canlib.VectorBus.get_application_config(
254+
app_name="CANalyzer",
255+
app_channel=0,
256+
bus_type=xldefine.XL_BusTypes.XL_BUS_TYPE_CAN,
257+
)
258+
assert canlib.xldriver.xlGetApplConfig.called
259+
260+
def test_set_application_config(self) -> None:
261+
canlib.xldriver.xlSetApplConfig = Mock()
262+
canlib.VectorBus.set_application_config(
263+
app_name="CANalyzer",
264+
app_channel=0,
265+
hw_type=xldefine.XL_HardwareType.XL_HWTYPE_VN1610,
266+
hw_index=0,
267+
hw_channel=0,
268+
bus_type=xldefine.XL_BusTypes.XL_BUS_TYPE_CAN,
269+
)
270+
assert canlib.xldriver.xlSetApplConfig.called
271+
272+
def test_set_timer_rate(self) -> None:
273+
canlib.xldriver.xlSetTimerRate = Mock()
274+
bus: canlib.VectorBus = can.Bus(
275+
channel=0, bustype="vector", fd=True, _testing=True
276+
)
277+
bus.set_timer_rate(timer_rate_ms=1)
278+
assert canlib.xldriver.xlSetTimerRate.called
279+
251280
def test_called_without_testing_argument(self) -> None:
252281
"""This tests if an exception is thrown when we are not running on Windows."""
253282
if os.name != "nt":

0 commit comments

Comments
 (0)