Skip to content

Commit

Permalink
Properly join list of methods in _DynamicCapabilityClient
Browse files Browse the repository at this point in the history
This was already fixed in c9bea05, 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.
  • Loading branch information
Fabio Rossetto authored and haata committed Nov 2, 2023
1 parent c9bea05 commit 42665a6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion capnp/lib/capnp.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 7 additions & 0 deletions test/test_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 42665a6

Please sign in to comment.