Fixes #61 It turns out I messed up the Server initialization code for the case where a string is passed in as the address. The tests only cover the cases where a raw socket is passed in. This will be rectified in a following commit.
36 lines
1.0 KiB
Python
36 lines
1.0 KiB
Python
import capnp
|
|
import os
|
|
import socket
|
|
import gc
|
|
|
|
import sys # add examples dir to sys.path
|
|
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'examples'))
|
|
import calculator_client
|
|
import calculator_server
|
|
|
|
|
|
def test_calculator():
|
|
read, write = socket.socketpair(socket.AF_UNIX)
|
|
|
|
server = capnp.TwoPartyServer(write, bootstrap=calculator_server.CalculatorImpl())
|
|
calculator_client.main(read)
|
|
|
|
|
|
def test_calculator_gc():
|
|
def new_evaluate_impl(old_evaluate_impl):
|
|
def call(*args, **kwargs):
|
|
gc.collect()
|
|
return old_evaluate_impl(*args, **kwargs)
|
|
return call
|
|
|
|
read, write = socket.socketpair(socket.AF_UNIX)
|
|
|
|
# inject a gc.collect to the beginning of every evaluate_impl call
|
|
evaluate_impl_orig = calculator_server.evaluate_impl
|
|
calculator_server.evaluate_impl = new_evaluate_impl(evaluate_impl_orig)
|
|
|
|
server = capnp.TwoPartyServer(write, bootstrap=calculator_server.CalculatorImpl())
|
|
calculator_client.main(read)
|
|
|
|
calculator_server.evaluate_impl = evaluate_impl_orig
|