6
6
import unittest
7
7
from unittest import mock
8
8
from unittest .mock import Mock
9
- from can .bus import BusState
10
- from can .interfaces .pcan .basic import *
11
- from can .interfaces .pcan import PcanBus
12
- from parameterized import parameterized
13
9
14
10
import pytest
11
+ from parameterized import parameterized
15
12
16
13
import can
17
- from can .interfaces .pcan import pcan
14
+ from can .bus import BusState
15
+ from can .interfaces .pcan .basic import *
16
+ from can .interfaces .pcan import PcanBus , PcanError
18
17
19
18
20
19
class TestPCANBus (unittest .TestCase ):
@@ -37,19 +36,19 @@ def tearDown(self) -> None:
37
36
38
37
def test_bus_creation (self ) -> None :
39
38
self .bus = can .Bus (bustype = "pcan" )
40
- self .assertIsInstance (self .bus , pcan . PcanBus )
39
+ self .assertIsInstance (self .bus , PcanBus )
41
40
self .MockPCANBasic .assert_called_once ()
42
41
self .mock_pcan .Initialize .assert_called_once ()
43
42
self .mock_pcan .InitializeFD .assert_not_called ()
44
43
45
44
def test_bus_creation_state_error (self ) -> None :
46
45
with self .assertRaises (ctypes .ArgumentError ):
47
46
self .bus = can .Bus (bustype = "pcan" , state = BusState .ERROR )
48
- self .assertIsInstance (self .bus , pcan . PcanBus )
47
+ self .assertIsInstance (self .bus , PcanBus )
49
48
50
49
def test_bus_creation_fd (self ) -> None :
51
50
self .bus = can .Bus (bustype = "pcan" , fd = True )
52
- self .assertIsInstance (self .bus , pcan . PcanBus )
51
+ self .assertIsInstance (self .bus , PcanBus )
53
52
self .MockPCANBasic .assert_called_once ()
54
53
self .mock_pcan .Initialize .assert_not_called ()
55
54
self .mock_pcan .InitializeFD .assert_called_once ()
@@ -254,7 +253,7 @@ def test_send_error(self) -> None:
254
253
arbitration_id = 0xC0FFEF , data = [1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 ], is_extended_id = True
255
254
)
256
255
257
- with self .assertRaises (pcan . PcanError ):
256
+ with self .assertRaises (PcanError ):
258
257
self .bus .send (msg )
259
258
260
259
@parameterized .expand ([("on" , True ), ("off" , False )])
0 commit comments