def verifyingclient(key_file, crt_file): server = TestServer(HOST, MathService()) server.start() try: client = VerifyingClient(server.port, key_file, crt_file) try: yield client finally: client.close() finally: server.stop()
def test_block_socket(self): server = TestServer(HOST, MathService()) timeout = server.get_timeout() server.start() try: with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as client_socket: client_socket.settimeout(timeout) client_socket.connect((HOST, server.port)) # Wait for data that will never arrive. # This will return successfuly if the other side closes the # connection (as expected) or raise timeout (which means the # test failed) client_socket.recv(100) finally: server.stop()
def test_block_socket(self): server = TestServer(HOST, MathService()) timeout = server.get_timeout() server.start() try: with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as client_socket: client_socket.settimeout(timeout) client_socket.connect((HOST, server.port)) # Wait for data that will never arrive. # This will return successfully if the other side closes the # connection (as expected) or raise timeout (which means the # test failed) client_socket.recv(100) finally: server.stop()