Skip to content

Commit 48b2acf

Browse files
committed
simplify IXXAT interface test
1 parent 4e0ae77 commit 48b2acf

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

test/test_interface_ixxat.py

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,20 @@ def setUp(self):
1919
bus = can.Bus(interface="ixxat", channel=0)
2020
bus.shutdown()
2121
except ImportError:
22-
raise (unittest.SkipTest())
23-
24-
def tearDown(self):
25-
pass
22+
raise unittest.SkipTest("not available on this platform")
2623

2724
def test_bus_creation(self):
2825
# channel must be >= 0
2926
with self.assertRaises(ValueError):
30-
bus = can.Bus(interface="ixxat", channel=-1)
27+
can.Bus(interface="ixxat", channel=-1)
3128

3229
# rxFifoSize must be > 0
3330
with self.assertRaises(ValueError):
34-
bus = can.Bus(interface="ixxat", channel=0, rxFifoSize=0)
31+
can.Bus(interface="ixxat", channel=0, rxFifoSize=0)
3532

3633
# txFifoSize must be > 0
3734
with self.assertRaises(ValueError):
38-
bus = can.Bus(interface="ixxat", channel=0, txFifoSize=0)
35+
can.Bus(interface="ixxat", channel=0, txFifoSize=0)
3936

4037

4138
class HardwareTestCase(unittest.TestCase):
@@ -48,22 +45,17 @@ def setUp(self):
4845
bus = can.Bus(interface="ixxat", channel=0)
4946
bus.shutdown()
5047
except ImportError:
51-
raise (unittest.SkipTest())
52-
53-
def tearDown(self):
54-
pass
48+
raise unittest.SkipTest("not available on this platform")
5549

5650
def test_bus_creation(self):
5751
# non-existent channel -> use arbitrary high value
5852
with self.assertRaises(can.CanInitializationError):
59-
bus = can.Bus(interface="ixxat", channel=0xFFFF)
53+
can.Bus(interface="ixxat", channel=0xFFFF)
6054

6155
def test_send_after_shutdown(self):
62-
bus = can.Bus(interface="ixxat", channel=0)
63-
msg = can.Message(arbitration_id=0x3FF, dlc=0)
64-
bus.shutdown()
65-
with self.assertRaises(can.CanOperationError):
66-
bus.send(msg)
56+
with can.Bus(interface="ixxat", channel=0) as bus:
57+
with self.assertRaises(can.CanOperationError):
58+
bus.send(can.Message(arbitration_id=0x3FF, dlc=0))
6759

6860

6961
if __name__ == "__main__":

0 commit comments

Comments
 (0)