lib.wiring: create flipped interface from flipped signature.
Fixes #914. Co-authored-by: Nelson Gauthier <nelson.gauthier@gmail.com>
This commit is contained in:
parent
b871f2ad79
commit
a90bc7b91a
|
@ -535,6 +535,9 @@ class FlippedSignature:
|
||||||
def __setattr__(self, name, value):
|
def __setattr__(self, name, value):
|
||||||
return setattr(self.__unflipped, name, value)
|
return setattr(self.__unflipped, name, value)
|
||||||
|
|
||||||
|
def create(self, *, path=()):
|
||||||
|
return flipped(self.__unflipped.create(path=path))
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f"{self.__unflipped!r}.flip()"
|
return f"{self.__unflipped!r}.flip()"
|
||||||
|
|
||||||
|
|
|
@ -583,6 +583,18 @@ class FlippedInterfaceTestCase(unittest.TestCase):
|
||||||
with self.assertRaisesRegex(TypeError,
|
with self.assertRaisesRegex(TypeError,
|
||||||
r"^flipped\(\) can only flip an interface object, not Signature\({}\)$"):
|
r"^flipped\(\) can only flip an interface object, not Signature\({}\)$"):
|
||||||
flipped(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):
|
class ConnectTestCase(unittest.TestCase):
|
||||||
|
|
Loading…
Reference in a new issue