The test coverage of the language server is not working with the current setup if the language server is also implemented in python.
The problem seems to be, that client.shutdown_session() is not waiting for the async subprocess to finish gracefully.
The following workaround seems to work.
@pytest_lsp.fixture( # type: ignore[misc]
config=ClientServerConfig(
server_command=[sys.executable, "..."],
)
)
async def client(lsp_client: LanguageClient): # type: ignore[no-untyped-def]
# Setup
await lsp_client.initialize_session(
InitializeParams(
capabilities=client_capabilities("visual-studio-code"),
)
)
yield lsp_client
# Teardown
await lsp_client.shutdown_session()
# Needed, otherwise the coverage of the server process is not collected.
server_process = lsp_client._server
if server_process:
await server_process.wait()
The test coverage of the language server is not working with the current setup if the language server is also implemented in python. The problem seems to be, that
client.shutdown_session()
is not waiting for the async subprocess to finish gracefully.The following workaround seems to work.