Skip to content

Commit d046eb6

Browse files
Atabeyzariiii9003
Atabey
authored andcommitted
add unit tests, fix build error
1 parent 426c22c commit d046eb6

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

can/interfaces/pcan/pcan.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
PCAN_CHANNEL_FEATURES,
5757
FEATURE_FD_CAPABLE,
5858
PCAN_DICT_STATUS,
59+
PCAN_BUSOFF_AUTORESET
5960
)
6061

6162

test/test_pcan.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,16 @@ def get_value_side_effect(handle, param):
363363
self.bus = can.Bus(bustype="pcan", device_id=dev_id)
364364
self.assertEqual(expected_result, self.bus.channel_info)
365365

366+
def test_bus_creation_auto_reset(self):
367+
self.bus = can.Bus(bustype="pcan", auto_reset=True)
368+
self.assertIsInstance(self.bus, PcanBus)
369+
self.MockPCANBasic.assert_called_once()
370+
371+
def test_auto_reset_init_fault(self):
372+
self.mock_pcan.SetValue = Mock(return_value=PCAN_ERROR_INITIALIZE)
373+
with self.assertRaises(CanInitializationError):
374+
self.bus = can.Bus(bustype="pcan", auto_reset=True)
375+
366376

367377
if __name__ == "__main__":
368378
unittest.main()

0 commit comments

Comments
 (0)