def step_impl(context): context._server_alive = False host, port = ('0.0.0.0', 20801) with mock.patch('coala_langserver.langserver.log') as mock_log: mock_log.side_effect = gen_alt_log(context) sys.argv = ['', '--mode', 'tcp', '--addr', str(port)] context.thread = Thread(target=main) context.thread.daemon = True context.thread.start() for _ in range(20): if context._server_alive: break else: time.sleep(1) else: assert False context.sock = socket.create_connection(address=(host, port), timeout=10) context.f = context.sock.makefile('rwb') context.reader = streams.JsonRpcStreamReader(context.f) context.writer = streams.JsonRpcStreamWriter(context.f)
def step_impl(context): context.f = tempfile.TemporaryFile() context.writer = streams.JsonRpcStreamWriter(context.f) request = { 'method': 'initialize', 'params': { 'rootUri': '/Users/mock-user/mock-dir', 'capabilities': {}, }, 'id': 1, 'jsonrpc': '2.0', } context.writer.write(request) context.f.seek(0)
def step_impl(context): context.f = tempfile.TemporaryFile() context.writer = streams.JsonRpcStreamWriter(context.f) context.writer.write(context.request)
def step_impl(context): context.f = tempfile.TemporaryFile(mode='w+b') context.writer = streams.JsonRpcStreamWriter(context.f) context.writer.write(context.message)