Support _DynamicListReader in _setDynamicField

See the test for an explanation.

Note that I'm not sure what the purpose of `_setDynamicFieldWithField` and
`_setDynamicFieldStatic` is. It does not appear to be used. I've kept them for
now (they are a public API), but perhaps this can be removed.
This commit is contained in:
Lasse Blaauwbroek
2023-11-07 05:18:29 +01:00
committed by Jacob Alexander
parent aafec2281e
commit ef5e039067
4 changed files with 37 additions and 0 deletions

View File

@@ -26,6 +26,12 @@ class Server(capability.TestInterface.Server):
async def bam(self, i, **kwargs):
return str(i) + "_test", i
async def bak1(self, **kwargs):
return [1, 2, 3, 4, 5]
async def bak2(self, i, **kwargs):
assert i[4] == 5
class PipelineServer(capability.TestPipeline.Server):
async def getCap(self, n, inCap, _context, **kwargs):
@@ -67,6 +73,12 @@ async def test_client():
with pytest.raises(AttributeError):
req.baz = 1
resp = await client.bak1()
# Used to fail with
# capnp.lib.capnp.KjException: Tried to set field: 'i' with a value of: '[1, 2, 3, 4, 5]'
# which is an unsupported type: '<class 'capnp.lib.capnp._DynamicListReader'>'
await client.bak2(resp.i)
async def test_simple_client():
client = capability.TestInterface._new_client(Server())