Skip to content

Commit 43d38d9

Browse files
committed
tests/extmod_hardware/machine_encoder.py: Separate the connection test.
Because it requires a different configuration of the pins (in `setUp`). Eg on mimxrt pins used for an Encoder cannot be read. Signed-off-by: Damien George <damien@micropython.org>
1 parent b64f4f9 commit 43d38d9

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

tests/extmod_hardware/machine_encoder.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,21 @@
2828
in1_pin = Pin(in1_pin, mode=Pin.IN)
2929

3030

31+
class TestConnections(unittest.TestCase):
32+
def setUp(self):
33+
in0_pin.init(Pin.IN)
34+
in1_pin.init(Pin.IN)
35+
36+
def test_connections(self):
37+
# Test the hardware connections are correct. If this test fails, all tests will fail.
38+
for ch, outp, inp in ((0, out0_pin, in0_pin), (1, out1_pin, in1_pin)):
39+
print("Testing channel ", ch)
40+
outp(1)
41+
self.assertEqual(1, inp())
42+
outp(0)
43+
self.assertEqual(0, inp())
44+
45+
3146
class TestEncoder(unittest.TestCase):
3247
def setUp(self):
3348
out0_pin(PIN_INIT_VALUE)
@@ -93,16 +108,6 @@ def assertPosition(self, value, value2=None, value4=None):
93108
self.assertEqual(self.enc4.value(), value4)
94109
pass
95110

96-
@unittest.skipIf(sys.platform == "mimxrt", "cannot read back the pin")
97-
def test_connections(self):
98-
# Test the hardware connections are correct. If this test fails, all tests will fail.
99-
for ch, outp, inp in ((0, out0_pin, in0_pin), (1, out1_pin, in1_pin)):
100-
print("Testing channel ", ch)
101-
outp(1)
102-
self.assertEqual(1, inp())
103-
outp(0)
104-
self.assertEqual(0, inp())
105-
106111
def test_basics(self):
107112
self.assertPosition(0)
108113
self.rotate(100)

0 commit comments

Comments
 (0)