Skip to content

Commit 7fb9acc

Browse files
committed
Provide a pylsp sleep helper based on ALS_WAIT_FACTOR
1 parent 9a357dc commit 7fb9acc

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

testsuite/ada_lsp/configuration_warning_null_setting/test.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
not when resetting it using a null value for a setting.
44
"""
55

6-
import asyncio
76
from drivers.pylsp import (
87
ALSLanguageClient,
98
assertEqual,
@@ -43,7 +42,7 @@ async def main(lsp: ALSLanguageClient) -> None:
4342
)
4443

4544
# Wait for didChangeConfig to be handled
46-
await asyncio.sleep(2)
45+
await lsp.sleep(2)
4746

4847
total_log_msg = len(lsp.log_messages)
4948
total_show_msg = len(lsp.messages)
@@ -54,7 +53,7 @@ async def main(lsp: ALSLanguageClient) -> None:
5453
lsp.didChangeConfig({"logThreshold": None, "insertWithClauses": None})
5554

5655
# Wait for didChangeConfig to be handled
57-
await asyncio.sleep(2)
56+
await lsp.sleep(2)
5857

5958
# Check that no messages were sent after using None/null as the value for
6059
# a setting

testsuite/drivers/pylsp.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,11 @@ def assertLocationsList(
480480
"""
481481
assertLocationsList(actual, expected)
482482

483+
async def sleep(self, seconds: float) -> None:
484+
"""Wait for the given amount of seconds multiplied by ALS_WAIT_FACTOR."""
485+
wait_factor: int = int(os.environ.get("ALS_WAIT_FACTOR", "1"))
486+
await asyncio.sleep(seconds * wait_factor)
487+
483488

484489
def als_client_factory() -> ALSLanguageClient:
485490
"""This function is an ugly copy-paste of pytest_lsp.make_test_lsp_client. It is

0 commit comments

Comments
 (0)