Adding examples as pytest tests

- This way they will be included in CI checks
- Decreased the delay time in the thread-like examples to speed up tests
(probably could decrease the time some more)
- Added an async version of the calculator test
- Forcing python3 support for example scripts
This commit is contained in:
Jacob Alexander
2019-09-27 14:40:54 -07:00
parent 58a5c5fc1f
commit 78776de647
12 changed files with 596 additions and 13 deletions

View File

@@ -1,8 +1,9 @@
#!/usr/bin/env python
#!/usr/bin/env python3
from __future__ import print_function
import argparse
import os
import capnp
import thread_capnp
@@ -11,6 +12,9 @@ import socket
import ssl
this_dir = os.path.dirname(os.path.abspath(__file__))
class ExampleImpl(thread_capnp.Example.Server):
"Implementation of the Example threading Cap'n Proto interface."
@@ -21,7 +25,7 @@ class ExampleImpl(thread_capnp.Example.Server):
.then(lambda _: self.subscribeStatus(subscriber))
def longRunning(self, **kwargs):
return capnp.getTimer().after_delay(3 * 10**9)
return capnp.getTimer().after_delay(1 * 10**9)
async def myreader(server, reader):
@@ -68,7 +72,7 @@ async def main():
# Setup SSL context
ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
ctx.load_cert_chain('selfsigned.cert', 'selfsigned.key')
ctx.load_cert_chain(os.path.join(this_dir, 'selfsigned.cert'), os.path.join(this_dir, 'selfsigned.key'))
# Handle both IPv4 and IPv6 cases
try: