Skip to content

Commit 599ab8d

Browse files
committed
Clean up pcan_test: Group imports and remove redundant one
1 parent e5ad332 commit 599ab8d

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

can/interfaces/pcan/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
"""
22
"""
33

4-
from can.interfaces.pcan.pcan import PcanBus
4+
from can.interfaces.pcan.pcan import PcanBus, PcanError

test/test_pcan.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@
66
import unittest
77
from unittest import mock
88
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
139

1410
import pytest
11+
from parameterized import parameterized
1512

1613
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
1817

1918

2019
class TestPCANBus(unittest.TestCase):
@@ -37,19 +36,19 @@ def tearDown(self) -> None:
3736

3837
def test_bus_creation(self) -> None:
3938
self.bus = can.Bus(bustype="pcan")
40-
self.assertIsInstance(self.bus, pcan.PcanBus)
39+
self.assertIsInstance(self.bus, PcanBus)
4140
self.MockPCANBasic.assert_called_once()
4241
self.mock_pcan.Initialize.assert_called_once()
4342
self.mock_pcan.InitializeFD.assert_not_called()
4443

4544
def test_bus_creation_state_error(self) -> None:
4645
with self.assertRaises(ctypes.ArgumentError):
4746
self.bus = can.Bus(bustype="pcan", state=BusState.ERROR)
48-
self.assertIsInstance(self.bus, pcan.PcanBus)
47+
self.assertIsInstance(self.bus, PcanBus)
4948

5049
def test_bus_creation_fd(self) -> None:
5150
self.bus = can.Bus(bustype="pcan", fd=True)
52-
self.assertIsInstance(self.bus, pcan.PcanBus)
51+
self.assertIsInstance(self.bus, PcanBus)
5352
self.MockPCANBasic.assert_called_once()
5453
self.mock_pcan.Initialize.assert_not_called()
5554
self.mock_pcan.InitializeFD.assert_called_once()
@@ -254,7 +253,7 @@ def test_send_error(self) -> None:
254253
arbitration_id=0xC0FFEF, data=[1, 2, 3, 4, 5, 6, 7, 8], is_extended_id=True
255254
)
256255

257-
with self.assertRaises(pcan.PcanError):
256+
with self.assertRaises(PcanError):
258257
self.bus.send(msg)
259258

260259
@parameterized.expand([("on", True), ("off", False)])

0 commit comments

Comments
 (0)