class Pins:
- def __init__(self, names, *, dir="io", conn=None, assert_width=None):
+ def __init__(self, names, *, dir="io", invert=False, conn=None, assert_width=None):
if not isinstance(names, str):
raise TypeError("Names must be a whitespace-separated string, not {!r}"
.format(names))
self.names = names
self.dir = dir
- self.invert = False
+ self.invert = bool(invert)
def __len__(self):
return len(self.names)
self.assertEqual(repr(p), "(pins-n io A0)")
self.assertEqual(p.invert, True)
+ def test_invert_arg(self):
+ p = Pins("A0", invert=True)
+ self.assertEqual(p.invert, True)
+
def test_conn(self):
p = Pins("0 1 2", conn=("pmod", 0))
self.assertEqual(list(p), ["pmod_0:0", "pmod_0:1", "pmod_0:2"])