Skip to content

Commit 003091c

Browse files
committed
test: add capability matching tests for LSP clients
1 parent 7a0759c commit 003091c

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

tests/__init__.py

Whitespace-only changes.

tests/test_capabilities.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from __future__ import annotations
2+
3+
import pytest
4+
5+
from lsp_client import LSPClient
6+
from lsp_client.clients import local_clients
7+
from lsp_client.utils.inspect import inspect_capabilities
8+
9+
10+
@pytest.mark.asyncio
11+
@pytest.mark.parametrize(
12+
"client_cls",
13+
local_clients,
14+
)
15+
async def test_capabilities_match(client_cls: type[LSPClient]):
16+
# instantiate the client directly to get its default server
17+
client = client_cls()
18+
server = client.server
19+
20+
mismatches = []
21+
async for result in inspect_capabilities(server, client_cls):
22+
if result.client != result.server:
23+
mismatches.append(
24+
f"{result.capability}: client={result.client}, server={result.server}"
25+
)
26+
27+
if mismatches:
28+
pytest.fail(
29+
f"Capability mismatch for {client_cls.__name__}:\n" + "\n".join(mismatches)
30+
)

0 commit comments

Comments
 (0)