Skip to content

Commit

Permalink
pytest-lsp: Fix casing for window.work_done_progress
Browse files Browse the repository at this point in the history
  • Loading branch information
alcarney committed Dec 13, 2023
1 parent 9f48951 commit fbef035
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/pytest-lsp/changes/119.fix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`LspSpecificationWarnings` will no longer be incorrectly emitted when a client does indeed support `window/workDoneProgress/create` requests
2 changes: 1 addition & 1 deletion lib/pytest-lsp/pytest_lsp/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def work_done_progress_create(
):
"""Assert that the client has support for ``window/workDoneProgress/create``
requests."""
is_supported = get_capability(capabilities, "window.workDoneProgress", False)
is_supported = get_capability(capabilities, "window.work_done_progress", False)
assert is_supported, "Client does not support 'window/workDoneProgress/create'"


Expand Down
27 changes: 25 additions & 2 deletions lib/pytest-lsp/tests/test_checks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Any
from typing import Optional

import pytest
from lsprotocol import types
Expand All @@ -22,6 +23,14 @@
types.WorkDoneProgressCreateParams(token="id-123"),
"does not support 'window/workDoneProgress/create'",
),
(
types.ClientCapabilities(
window=types.WindowClientCapabilities(work_done_progress=True)
),
types.WINDOW_WORK_DONE_PROGRESS_CREATE,
types.WorkDoneProgressCreateParams(token="id-123"),
None,
),
(
types.ClientCapabilities(
workspace=types.WorkspaceClientCapabilities(configuration=False)
Expand All @@ -33,7 +42,11 @@
],
)
def test_params_check_warning(
capabilities: types.ClientCapabilities, method: str, params: Any, expected: str
capabilities: types.ClientCapabilities,
method: str,
params: Any,
expected: Optional[str],
recwarn,
):
"""Ensure that parameter checks work as expected.
Expand All @@ -50,10 +63,20 @@ def test_params_check_warning(
expected
The expected warning message
recwarn
Builtin fixture from pytest for recording warnings
"""

with pytest.warns(checks.LspSpecificationWarning, match=expected):
if expected is None:
checks.check_params_against_client_capabilities(capabilities, method, params)
assert len(recwarn) == 0

else:
with pytest.warns(checks.LspSpecificationWarning, match=expected):
checks.check_params_against_client_capabilities(
capabilities, method, params
)


@pytest.mark.parametrize(
Expand Down

0 comments on commit fbef035

Please sign in to comment.