lib.wiring: ensure flipped(flipped(intf)) is intf.

This commit is contained in:
Catherine 2023-09-01 05:26:59 +00:00
parent 5a17f94fdc
commit f28b20fc84
2 changed files with 5 additions and 1 deletions

View file

@ -552,7 +552,10 @@ class FlippedInterface:
def flipped(interface): def flipped(interface):
return FlippedInterface(interface) if type(interface) is FlippedInterface:
return interface._FlippedInterface__unflipped
else:
return FlippedInterface(interface)
@final @final

View file

@ -530,6 +530,7 @@ class FlippedInterfaceTestCase(unittest.TestCase):
self.assertEqual(tintf, flipped(intf)) self.assertEqual(tintf, flipped(intf))
self.assertRegex(repr(tintf), self.assertRegex(repr(tintf),
r"^flipped\(<.+?\.Interface object at .+>\)$") r"^flipped\(<.+?\.Interface object at .+>\)$")
self.assertIs(flipped(tintf), intf)
def test_getattr_setattr(self): def test_getattr_setattr(self):
class I(Interface): class I(Interface):