-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support
initializationOptions
to configure the server (#459)
- Loading branch information
1 parent
b864c4f
commit 1f415b5
Showing
3 changed files
with
60 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Copyright 2021- Python Language Server Contributors. | ||
|
||
from unittest.mock import patch | ||
|
||
from test.test_utils import send_initialize_request | ||
from test.test_notebook_document import wait_for_condition | ||
|
||
import pytest | ||
|
||
from pylsp import IS_WIN | ||
|
||
|
||
INITIALIZATION_OPTIONS = { | ||
"pylsp": { | ||
"plugins": { | ||
"flake8": {"enabled": True}, | ||
"pycodestyle": {"enabled": False}, | ||
"pyflakes": {"enabled": False}, | ||
}, | ||
} | ||
} | ||
|
||
|
||
@pytest.mark.skipif(IS_WIN, reason="Flaky on Windows") | ||
def test_set_flake8_using_init_opts(client_server_pair): | ||
client, server = client_server_pair | ||
send_initialize_request(client, INITIALIZATION_OPTIONS) | ||
for key, value in INITIALIZATION_OPTIONS["pylsp"]["plugins"].items(): | ||
assert server.workspace._config.settings().get("plugins").get(key).get( | ||
"enabled" | ||
) == value.get("enabled") | ||
|
||
|
||
@pytest.mark.skipif(IS_WIN, reason="Flaky on Windows") | ||
def test_set_flake8_using_workspace_did_change_configuration(client_server_pair): | ||
client, server = client_server_pair | ||
send_initialize_request(client, None) | ||
assert ( | ||
server.workspace._config.settings().get("plugins").get("flake8").get("enabled") | ||
is False | ||
) | ||
|
||
with patch.object(server.workspace, "update_config") as mock_update_config: | ||
client._endpoint.notify( | ||
"workspace/didChangeConfiguration", | ||
{"settings": INITIALIZATION_OPTIONS}, | ||
) | ||
wait_for_condition(lambda: mock_update_config.call_count >= 1) | ||
|
||
for key, value in INITIALIZATION_OPTIONS["pylsp"]["plugins"].items(): | ||
assert server.workspace._config.settings().get("plugins").get(key).get( | ||
"enabled" | ||
) == value.get("enabled") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters