.format(dir))
self.dir = dir
+ def __len__(self):
+ return len(self.names)
+
+ def __iter__(self):
+ return iter(self.names)
+
def __repr__(self):
return "(pins {} {})".format(self.dir, " ".join(self.names))
self.dir = dir
+ def __len__(self):
+ return len(self.p.names)
+
+ def __iter__(self):
+ return zip(self.p.names, self.n.names)
+
def __repr__(self):
return "(diffpairs {} (p {}) (n {}))".format(
self.dir, " ".join(self.p.names), " ".join(self.n.names))
self.assertEqual(repr(p), "(pins io A0 A1 A2)")
self.assertEqual(len(p.names), 3)
self.assertEqual(p.dir, "io")
+ self.assertEqual(list(p), ["A0", "A1", "A2"])
def test_wrong_names(self):
with self.assertRaises(TypeError,
self.assertEqual(dp.p.names, ["A0", "A1"])
self.assertEqual(dp.n.names, ["B0", "B1"])
self.assertEqual(dp.dir, "io")
+ self.assertEqual(list(dp), [("A0", "B0"), ("A1", "B1")])
def test_dir(self):
dp = DiffPairs("A0", "B0", dir="o")