lib.io: Add missing __repr__ to signature type.
This commit is contained in:
parent
8af9fe2606
commit
1dd2e6150c
|
@ -114,6 +114,10 @@ class Pin(wiring.PureInterface):
|
|||
self.dir == other.dir and
|
||||
self.xdr == other.xdr)
|
||||
|
||||
def __repr__(self):
|
||||
xdr = f", xdr={self.xdr}" if self.xdr != 0 else ""
|
||||
return f"Pin.Signature({self.width}, dir={self.dir!r}{xdr})"
|
||||
|
||||
def create(self, *, path=None, src_loc_at=0):
|
||||
return Pin(self.width, self.dir, xdr=self.xdr, path=path, src_loc_at=1 + src_loc_at)
|
||||
|
||||
|
|
|
@ -199,6 +199,16 @@ class PinSignatureDDRTestCase(PinSignatureTestCase):
|
|||
})
|
||||
|
||||
|
||||
class PinSignatureReprCase(FHDLTestCase):
|
||||
def test_repr(self):
|
||||
sig_0 = Pin.Signature(1, dir="i")
|
||||
self.assertRepr(sig_0, "Pin.Signature(1, dir='i')")
|
||||
sig_0 = Pin.Signature(2, dir="o", xdr=1)
|
||||
self.assertRepr(sig_0, "Pin.Signature(2, dir='o', xdr=1)")
|
||||
sig_0 = Pin.Signature(3, dir="io", xdr=2)
|
||||
self.assertRepr(sig_0, "Pin.Signature(3, dir='io', xdr=2)")
|
||||
|
||||
|
||||
class PinTestCase(FHDLTestCase):
|
||||
def test_attributes(self):
|
||||
pin = Pin(2, dir="io", xdr=2)
|
||||
|
@ -208,4 +218,3 @@ class PinTestCase(FHDLTestCase):
|
|||
self.assertEqual(pin.signature.width, 2)
|
||||
self.assertEqual(pin.signature.dir, "io")
|
||||
self.assertEqual(pin.signature.xdr, 2)
|
||||
|
||||
|
|
Loading…
Reference in a new issue