From 43d38d995e85ede82de728a9e9949ba69da8042a Mon Sep 17 00:00:00 2001 From: Damien George Date: Fri, 2 Jan 2026 17:00:24 +1100 Subject: [PATCH] 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 --- tests/extmod_hardware/machine_encoder.py | 25 ++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/tests/extmod_hardware/machine_encoder.py b/tests/extmod_hardware/machine_encoder.py index c218c8bfb6..67d1b5f443 100644 --- a/tests/extmod_hardware/machine_encoder.py +++ b/tests/extmod_hardware/machine_encoder.py @@ -28,6 +28,21 @@ out1_pin = Pin(out1_pin, mode=Pin.OUT) in1_pin = Pin(in1_pin, mode=Pin.IN) +class TestConnections(unittest.TestCase): + def setUp(self): + in0_pin.init(Pin.IN) + in1_pin.init(Pin.IN) + + def test_connections(self): + # Test the hardware connections are correct. If this test fails, all tests will fail. + for ch, outp, inp in ((0, out0_pin, in0_pin), (1, out1_pin, in1_pin)): + print("Testing channel ", ch) + outp(1) + self.assertEqual(1, inp()) + outp(0) + self.assertEqual(0, inp()) + + class TestEncoder(unittest.TestCase): def setUp(self): out0_pin(PIN_INIT_VALUE) @@ -93,16 +108,6 @@ class TestEncoder(unittest.TestCase): self.assertEqual(self.enc4.value(), value4) pass - @unittest.skipIf(sys.platform == "mimxrt", "cannot read back the pin") - def test_connections(self): - # Test the hardware connections are correct. If this test fails, all tests will fail. - for ch, outp, inp in ((0, out0_pin, in0_pin), (1, out1_pin, in1_pin)): - print("Testing channel ", ch) - outp(1) - self.assertEqual(1, inp()) - outp(0) - self.assertEqual(0, inp()) - def test_basics(self): self.assertPosition(0) self.rotate(100)