From 42665a61c98e4559e7c82aa16c746a67be4d4b4c Mon Sep 17 00:00:00 2001 From: Fabio Rossetto Date: Wed, 1 Nov 2023 14:00:14 +0100 Subject: [PATCH] Properly join list of methods in _DynamicCapabilityClient This was already fixed in c9bea05f44, but the fix does not seem to work. This commit uses a set union, which should be more robust. It also adds a couple of assertions to verify that it indeed works. --- capnp/lib/capnp.pyx | 2 +- test/test_rpc.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/capnp/lib/capnp.pyx b/capnp/lib/capnp.pyx index e824b2e..6a858a9 100644 --- a/capnp/lib/capnp.pyx +++ b/capnp/lib/capnp.pyx @@ -2199,7 +2199,7 @@ cdef class _DynamicCapabilityClient: return self._cached_schema def __dir__(self): - return list(set(self.schema.method_names_inherited + tuple(dir(self.__class__)))) + return list(set(self.schema.method_names_inherited) | set(dir(self.__class__))) cdef class _CapabilityClient: diff --git a/test/test_rpc.py b/test/test_rpc.py index f340f02..2e918bd 100644 --- a/test/test_rpc.py +++ b/test/test_rpc.py @@ -51,6 +51,13 @@ async def test_simple_rpc_bootstrap(): cap = client.bootstrap() cap = cap.cast_as(test_capability_capnp.TestInterface) + # Check not only that the methods are there, but also that they are listed + # as expected. + assert "foo" in dir(cap) + assert "bar" in dir(cap) + assert "buz" in dir(cap) + assert "bam" in dir(cap) + remote = cap.foo(i=5) response = await remote