lib.wiring: create flipped interface from flipped signature.

Fixes #914.

Co-authored-by: Nelson Gauthier <nelson.gauthier@gmail.com>
This commit is contained in:
Catherine 2023-09-27 11:00:54 +00:00
parent b871f2ad79
commit a90bc7b91a
2 changed files with 15 additions and 0 deletions

View file

@ -535,6 +535,9 @@ class FlippedSignature:
def __setattr__(self, name, value):
return setattr(self.__unflipped, name, value)
def create(self, *, path=()):
return flipped(self.__unflipped.create(path=path))
def __repr__(self):
return f"{self.__unflipped!r}.flip()"

View file

@ -584,6 +584,18 @@ class FlippedInterfaceTestCase(unittest.TestCase):
r"^flipped\(\) can only flip an interface object, not Signature\({}\)$"):
flipped(Signature({}))
def test_create_subclass_flipped(self):
class CustomInterface(Interface):
def custom_method(self):
return 69
class CustomSignature(Signature):
def create(self, *, path=()):
return CustomInterface(self, path=path)
flipped_interface = CustomSignature({}).flip().create()
self.assertTrue(hasattr(flipped_interface, "custom_method"))
class ConnectTestCase(unittest.TestCase):
def test_arg_handles_and_signature_attr(self):