forked from robotics-4-all/tektrain-robot-sw
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_mc23x17.py
32 lines (21 loc) · 838 Bytes
/
test_mc23x17.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import unittest
import time
from pidevices.mcp23x17 import MCP23x17
class TestMCP23x17(unittest.TestCase):
def test_get_chunk(self):
device = MCP23x17()
address, number = device._get_chunk_number("A_2")
self.assertEqual(address, "A", "It should be A")
self.assertEqual(number, 2, "It should be 2")
with self.assertRaises(TypeError):
device._get_chunk_number(12)
with self.assertRaises(TypeError):
device._get_chunk_number("A_c")
with self.assertRaises(ValueError):
device._get_chunk_number("A_12")
with self.assertRaises(ValueError):
device._get_chunk_number("C_12")
with self.assertRaises(ValueError):
device._get_chunk_number("a_12")
if __name__ == "__main__":
unittest.main()