mirror of
https://github.com/capnproto/pycapnp.git
synced 2025-03-04 08:24:43 +01:00
Fix and improve a bunch of tests
This commit is contained in:
parent
b29f18ed64
commit
af99e388fb
4 changed files with 46 additions and 88 deletions
|
@ -29,10 +29,13 @@ class Server:
|
|||
|
||||
|
||||
class PipelineServer:
|
||||
def __init__(self, capability):
|
||||
self.capability = capability
|
||||
|
||||
def getCap_context(self, context):
|
||||
def _then(response):
|
||||
context.results.s = response.x + "_foo"
|
||||
context.results.outBox.cap = capability().TestInterface._new_server(
|
||||
context.results.outBox.cap = self.capability.TestInterface._new_server(
|
||||
Server(100)
|
||||
)
|
||||
|
||||
|
@ -126,16 +129,8 @@ async def test_simple_client_context(capability):
|
|||
remote = client.foo(baz=5)
|
||||
|
||||
|
||||
@pytest.mark.xfail
|
||||
def test_pipeline_context(capability):
|
||||
"""
|
||||
E capnp.lib.capnp.KjException: capnp/lib/capnp.pyx:61: failed: <class 'Failed'>:Fixture "capability" called directly. Fixtures are not meant to be called directly,
|
||||
E but are created automatically when test functions request them as parameters.
|
||||
E See https://docs.pytest.org/en/latest/fixture.html for more information about fixtures, and
|
||||
E https://docs.pytest.org/en/latest/deprecations.html#calling-fixtures-directly about how to update your code.
|
||||
E stack: 7f87c1ac6e40 7f87c17c3250 7f87c17be260 7f87c17c49f0 7f87c17c0f50 7f87c17c5540 7f87c17d7bf0 7f87c1acb768 7f87c1aaf185 7f87c1aaf2dc 7f87c1a6da1d 7f87c3895459 7f87c3895713 7f87c38c72eb 7f87c3901409 7f87c38b5767 7f87c38b6e7e 7f87c38fe48d 7f87c38b5767 7f87c38b6e7e 7f87c38fe48d 7f87c38b5767 7f87c38b67d2 7f87c38c71cf 7f87c38fdb77 7f87c38b5767 7f87c38b67d2 7f87c38c71cf 7f87c3901409 7f87c38b6632 7f87c38c71cf 7f87c3901409
|
||||
"""
|
||||
client = capability.TestPipeline._new_client(PipelineServer())
|
||||
async def test_pipeline_context(capability):
|
||||
client = capability.TestPipeline._new_client(PipelineServer(capability))
|
||||
foo_client = capability.TestInterface._new_client(Server())
|
||||
|
||||
remote = client.getCap(n=5, inCap=foo_client)
|
||||
|
@ -168,10 +163,13 @@ async def test_exception_client_context(capability):
|
|||
|
||||
|
||||
class BadPipelineServer:
|
||||
def __init__(self, capability):
|
||||
self.capability = capability
|
||||
|
||||
def getCap_context(self, context):
|
||||
def _then(response):
|
||||
context.results.s = response.x + "_foo"
|
||||
context.results.outBox.cap = capability().TestInterface._new_server(
|
||||
context.results.outBox.cap = self.capability.TestInterface._new_server(
|
||||
Server(100)
|
||||
)
|
||||
|
||||
|
@ -182,7 +180,7 @@ class BadPipelineServer:
|
|||
|
||||
|
||||
async def test_exception_chain_context(capability):
|
||||
client = capability.TestPipeline._new_client(BadPipelineServer())
|
||||
client = capability.TestPipeline._new_client(BadPipelineServer(capability))
|
||||
foo_client = capability.TestInterface._new_client(BadServer())
|
||||
|
||||
remote = client.getCap(n=5, inCap=foo_client)
|
||||
|
@ -194,7 +192,7 @@ async def test_exception_chain_context(capability):
|
|||
|
||||
|
||||
async def test_pipeline_exception_context(capability):
|
||||
client = capability.TestPipeline._new_client(BadPipelineServer())
|
||||
client = capability.TestPipeline._new_client(BadPipelineServer(capability))
|
||||
foo_client = capability.TestInterface._new_client(BadServer())
|
||||
|
||||
remote = client.getCap(n=5, inCap=foo_client)
|
||||
|
@ -241,8 +239,9 @@ class TailCaller:
|
|||
|
||||
|
||||
class TailCallee:
|
||||
def __init__(self):
|
||||
def __init__(self, capability):
|
||||
self.count = 0
|
||||
self.capability = capability
|
||||
|
||||
def foo_context(self, context):
|
||||
self.count += 1
|
||||
|
@ -250,19 +249,11 @@ class TailCallee:
|
|||
results = context.results
|
||||
results.i = context.params.i
|
||||
results.t = context.params.t
|
||||
results.c = capability().TestCallOrder._new_server(TailCallOrder())
|
||||
results.c = self.capability.TestCallOrder._new_server(TailCallOrder())
|
||||
|
||||
|
||||
@pytest.mark.xfail
|
||||
def test_tail_call(capability):
|
||||
"""
|
||||
E capnp.lib.capnp.KjException: capnp/lib/capnp.pyx:75: failed: <class 'Failed'>:Fixture "capability" called directly. Fixtures are not meant to be called directly,
|
||||
E but are created automatically when test functions request them as parameters.
|
||||
E See https://docs.pytest.org/en/latest/fixture.html for more information about fixtures, and
|
||||
E https://docs.pytest.org/en/latest/deprecations.html#calling-fixtures-directly about how to update your code.
|
||||
E stack: 7f87c17c5540 7f87c17c51b0 7f87c17c5540 7f87c17d7bf0 7f87c1acb768 7f87c1aaf185 7f87c1aaf2dc 7f87c1a6da1d 7f87c3895459 7f87c3895713 7f87c38c72eb 7f87c3901409 7f87c38b5767 7f87c38b6e7e 7f87c38fe48d 7f87c38b5767 7f87c38b6e7e 7f87c38fe48d 7f87c38b5767 7f87c38b67d2 7f87c38c71cf 7f87c38fdb77 7f87c38b5767 7f87c38b67d2 7f87c38c71cf 7f87c3901409 7f87c38b6632 7f87c38c71cf 7f87c3901409 7f87c38b5767 7f87c38b6e7e 7f87c388ace7
|
||||
"""
|
||||
callee_server = TailCallee()
|
||||
async def test_tail_call(capability):
|
||||
callee_server = TailCallee(capability)
|
||||
caller_server = TailCaller()
|
||||
|
||||
callee = capability.TestTailCallee._new_client(callee_server)
|
||||
|
|
|
@ -28,11 +28,14 @@ class Server:
|
|||
|
||||
|
||||
class PipelineServer:
|
||||
def __init__(self, capability):
|
||||
self.capability = capability
|
||||
|
||||
def getCap(self, n, inCap, _context, **kwargs):
|
||||
def _then(response):
|
||||
_results = _context.results
|
||||
_results.s = response.x + "_foo"
|
||||
_results.outBox.cap = capability().TestInterface._new_server(Server(100))
|
||||
_results.outBox.cap = self.capability.TestInterface._new_server(Server(100))
|
||||
|
||||
return inCap.foo(i=n).then(_then)
|
||||
|
||||
|
@ -124,16 +127,8 @@ async def test_simple_client(capability):
|
|||
remote = client.foo(baz=5)
|
||||
|
||||
|
||||
@pytest.mark.xfail
|
||||
def test_pipeline(capability):
|
||||
"""
|
||||
E capnp.lib.capnp.KjException: capnp/lib/capnp.pyx:61: failed: <class 'Failed'>:Fixture "capability" called directly. Fixtures are not meant to be called directly,
|
||||
E but are created automatically when test functions request them as parameters.
|
||||
E See https://docs.pytest.org/en/latest/fixture.html for more information about fixtures, and
|
||||
E https://docs.pytest.org/en/latest/deprecations.html#calling-fixtures-directly about how to update your code.
|
||||
E stack: 7f680f7fce40 7f680f4f9250 7f680f4f4260 7f680f4fa9f0 7f680f4f6f50 7f680f4fb540 7f680f50dbf0 7f680f801768 7f680f7e5185 7f680f7e52dc 7f680f7a3a1d 7f68115cb459 7f68115cb713 7f68115fd2eb 7f6811637409 7f68115eb767 7f68115ece7e 7f681163448d 7f68115eb767 7f68115ece7e 7f681163448d 7f68115eb767 7f68115ec7d2 7f68115fd1cf 7f6811633b77 7f68115eb767 7f68115ec7d2 7f68115fd1cf 7f6811637409 7f68115ec632 7f68115fd1cf 7f6811637409
|
||||
"""
|
||||
client = capability.TestPipeline._new_client(PipelineServer())
|
||||
async def test_pipeline(capability):
|
||||
client = capability.TestPipeline._new_client(PipelineServer(capability))
|
||||
foo_client = capability.TestInterface._new_client(Server())
|
||||
|
||||
remote = client.getCap(n=5, inCap=foo_client)
|
||||
|
@ -168,11 +163,14 @@ async def test_exception_client(capability):
|
|||
|
||||
|
||||
class BadPipelineServer:
|
||||
def __init__(self, capability):
|
||||
self.capability = capability
|
||||
|
||||
def getCap(self, n, inCap, _context, **kwargs):
|
||||
def _then(response):
|
||||
_results = _context.results
|
||||
_results.s = response.x + "_foo"
|
||||
_results.outBox.cap = capability().TestInterface._new_server(Server(100))
|
||||
_results.outBox.cap = self.capability.TestInterface._new_server(Server(100))
|
||||
|
||||
def _error(error):
|
||||
raise Exception("test was a success")
|
||||
|
@ -181,7 +179,7 @@ class BadPipelineServer:
|
|||
|
||||
|
||||
async def test_exception_chain(capability):
|
||||
client = capability.TestPipeline._new_client(BadPipelineServer())
|
||||
client = capability.TestPipeline._new_client(BadPipelineServer(capability))
|
||||
foo_client = capability.TestInterface._new_client(BadServer())
|
||||
|
||||
remote = client.getCap(n=5, inCap=foo_client)
|
||||
|
@ -193,7 +191,7 @@ async def test_exception_chain(capability):
|
|||
|
||||
|
||||
async def test_pipeline_exception(capability):
|
||||
client = capability.TestPipeline._new_client(BadPipelineServer())
|
||||
client = capability.TestPipeline._new_client(BadPipelineServer(capability))
|
||||
foo_client = capability.TestInterface._new_client(BadServer())
|
||||
|
||||
remote = client.getCap(n=5, inCap=foo_client)
|
||||
|
@ -238,8 +236,9 @@ class TailCaller:
|
|||
|
||||
|
||||
class TailCallee:
|
||||
def __init__(self):
|
||||
def __init__(self, capability):
|
||||
self.count = 0
|
||||
self.capability = capability
|
||||
|
||||
def foo(self, i, t, _context, **kwargs):
|
||||
self.count += 1
|
||||
|
@ -247,19 +246,11 @@ class TailCallee:
|
|||
results = _context.results
|
||||
results.i = i
|
||||
results.t = t
|
||||
results.c = capability().TestCallOrder._new_server(TailCallOrder())
|
||||
results.c = self.capability.TestCallOrder._new_server(TailCallOrder())
|
||||
|
||||
|
||||
@pytest.mark.xfail
|
||||
def test_tail_call(capability):
|
||||
"""
|
||||
E capnp.lib.capnp.KjException: capnp/lib/capnp.pyx:104: failed: <class 'Failed'>:Fixture "capability" called directly. Fixtures are not meant to be called directly,
|
||||
E but are created automatically when test functions request them as parameters.
|
||||
E See https://docs.pytest.org/en/latest/fixture.html for more information about fixtures, and
|
||||
E https://docs.pytest.org/en/latest/deprecations.html#calling-fixtures-directly about how to update your code.
|
||||
E stack: 7f680f4fb540 7f680f4fb1b0 7f680f4fb540 7f680f50dbf0 7f680f801768 7f680f7e5185 7f680f7e52dc 7f680f7a3a1d 7f68115cb459 7f68115cb713 7f68115fd2eb 7f6811637409 7f68115eb767 7f68115ece7e 7f681163448d 7f68115eb767 7f68115ece7e 7f681163448d 7f68115eb767 7f68115ec7d2 7f68115fd1cf 7f6811633b77 7f68115eb767 7f68115ec7d2 7f68115fd1cf 7f6811637409 7f68115ec632 7f68115fd1cf 7f6811637409 7f68115eb767 7f68115ece7e 7f68115c0ce7
|
||||
"""
|
||||
callee_server = TailCallee()
|
||||
async def test_tail_call(capability):
|
||||
callee_server = TailCallee(capability)
|
||||
caller_server = TailCaller()
|
||||
|
||||
callee = capability.TestTailCallee._new_client(callee_server)
|
||||
|
|
|
@ -117,8 +117,8 @@ def run_subprocesses(
|
|||
serverp.kill()
|
||||
|
||||
|
||||
def test_async_calculator_example(cleanup):
|
||||
address = "{}:36432".format(hostname)
|
||||
def test_async_calculator_example(unused_tcp_port, cleanup):
|
||||
address = "{}:{}".format(hostname, unused_tcp_port)
|
||||
server = "async_calculator_server.py"
|
||||
client = "async_calculator_client.py"
|
||||
run_subprocesses(address, server, client)
|
||||
|
@ -132,57 +132,36 @@ def test_addressbook_example(cleanup):
|
|||
assert ret == 0
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
sys.platform == "win32",
|
||||
reason="""
|
||||
Asyncio bug with libcapnp timer, likely due to asyncio starving some event loop.
|
||||
See https://github.com/capnproto/pycapnp/issues/196
|
||||
""",
|
||||
)
|
||||
def test_async_example(cleanup):
|
||||
address = "{}:36434".format(hostname)
|
||||
def test_async_example(unused_tcp_port, cleanup):
|
||||
address = "{}:{}".format(hostname, unused_tcp_port)
|
||||
server = "async_server.py"
|
||||
client = "async_client.py"
|
||||
run_subprocesses(address, server, client)
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
sys.platform == "win32",
|
||||
reason="""
|
||||
Asyncio bug with libcapnp timer, likely due to asyncio starving some event loop.
|
||||
See https://github.com/capnproto/pycapnp/issues/196
|
||||
""",
|
||||
)
|
||||
def test_ssl_async_example(cleanup):
|
||||
address = "{}:36435".format(hostname)
|
||||
def test_ssl_async_example(unused_tcp_port, cleanup):
|
||||
address = "{}:{}".format(hostname, unused_tcp_port)
|
||||
server = "async_ssl_server.py"
|
||||
client = "async_ssl_client.py"
|
||||
run_subprocesses(address, server, client, ipv4_force=False)
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
sys.platform == "win32",
|
||||
reason="""
|
||||
Asyncio bug with libcapnp timer, likely due to asyncio starving some event loop.
|
||||
See https://github.com/capnproto/pycapnp/issues/196
|
||||
""",
|
||||
)
|
||||
def test_ssl_reconnecting_async_example(cleanup):
|
||||
address = "{}:36436".format(hostname)
|
||||
def test_ssl_reconnecting_async_example(unused_tcp_port, cleanup):
|
||||
address = "{}:{}".format(hostname, unused_tcp_port)
|
||||
server = "async_ssl_server.py"
|
||||
client = "async_reconnecting_ssl_client.py"
|
||||
run_subprocesses(address, server, client, ipv4_force=False)
|
||||
|
||||
|
||||
def test_async_ssl_calculator_example(cleanup):
|
||||
address = "{}:36437".format(hostname)
|
||||
def test_async_ssl_calculator_example(unused_tcp_port, cleanup):
|
||||
address = "{}:{}".format(hostname, unused_tcp_port)
|
||||
server = "async_ssl_calculator_server.py"
|
||||
client = "async_ssl_calculator_client.py"
|
||||
run_subprocesses(address, server, client, ipv4_force=False)
|
||||
|
||||
|
||||
def test_async_socket_message_example(cleanup):
|
||||
address = "{}:36438".format(hostname)
|
||||
def test_async_socket_message_example(unused_tcp_port, cleanup):
|
||||
address = "{}:{}".format(hostname, unused_tcp_port)
|
||||
server = "async_socket_message_server.py"
|
||||
client = "async_socket_message_client.py"
|
||||
run_subprocesses(address, server, client)
|
||||
|
|
|
@ -81,9 +81,6 @@ def test_roundtrip_bytes_mmap(all_types):
|
|||
test_regression.check_all_types(msg)
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
sys.version_info[0] < 3, reason="memoryview is a builtin on Python 3"
|
||||
)
|
||||
def test_roundtrip_bytes_buffer(all_types):
|
||||
msg = all_types.TestAllTypes.new_message()
|
||||
test_regression.init_all_types(msg)
|
||||
|
|
Loading…
Add table
Reference in a new issue