-
Notifications
You must be signed in to change notification settings - Fork 233
Expand file tree
/
Copy pathtest_configuration.py
More file actions
53 lines (43 loc) · 1.73 KB
/
test_configuration.py
File metadata and controls
53 lines (43 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Copyright 2021- Python Language Server Contributors.
from unittest.mock import patch
import pytest
from pylsp import IS_WIN
from test.test_notebook_document import wait_for_condition
from test.test_utils import send_initialize_request
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) -> None:
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,
) -> None:
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")