summaryrefslogtreecommitdiffstats
path: root/tests/lsp_tests/conftest.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 20:16:53 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 20:16:53 +0000
commitee65fb850961435a3c8ed89ffb20d16f0e8505a3 (patch)
tree1fe559c0b1c6a2244e0e87e94c1d98222fa02e8c /tests/lsp_tests/conftest.py
parentAdding upstream version 0.1.24. (diff)
downloaddebputy-ee65fb850961435a3c8ed89ffb20d16f0e8505a3.tar.xz
debputy-ee65fb850961435a3c8ed89ffb20d16f0e8505a3.zip
Adding upstream version 0.1.25.upstream/0.1.25
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/lsp_tests/conftest.py')
-rw-r--r--tests/lsp_tests/conftest.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/lsp_tests/conftest.py b/tests/lsp_tests/conftest.py
new file mode 100644
index 0000000..8b42582
--- /dev/null
+++ b/tests/lsp_tests/conftest.py
@@ -0,0 +1,43 @@
+import pytest
+from debputy.plugin.api.feature_set import PluginProvidedFeatureSet
+
+try:
+ from pygls.server import LanguageServer
+ from lsprotocol.types import (
+ InitializeParams,
+ ClientCapabilities,
+ GeneralClientCapabilities,
+ PositionEncodingKind,
+ TextDocumentItem,
+ Position,
+ CompletionParams,
+ TextDocumentIdentifier,
+ HoverParams,
+ MarkupContent,
+ )
+ from debputy.lsp.lsp_features import lsp_set_plugin_features
+
+ HAS_PYGLS = True
+except ImportError:
+ HAS_PYGLS = False
+
+
+@pytest.fixture()
+def ls(debputy_plugin_feature_set: PluginProvidedFeatureSet) -> "LanguageServer":
+ if not HAS_PYGLS:
+ pytest.skip("Missing pygls")
+ ls = LanguageServer("debputy", "v<test>")
+ ls.lsp.lsp_initialize(
+ InitializeParams(
+ ClientCapabilities(
+ general=GeneralClientCapabilities(
+ position_encodings=[PositionEncodingKind.Utf32],
+ )
+ )
+ )
+ )
+ lsp_set_plugin_features(debputy_plugin_feature_set)
+ try:
+ yield ls
+ finally:
+ lsp_set_plugin_features(None)