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
commit7f62bd7daeb1c8e6d879b9e607474b457ea71aca (patch)
tree40de464ce4041327045d31b7c54d3b069309107a /tests/lsp_tests/conftest.py
parentAdding debian version 0.1.24. (diff)
downloaddebputy-7f62bd7daeb1c8e6d879b9e607474b457ea71aca.tar.xz
debputy-7f62bd7daeb1c8e6d879b9e607474b457ea71aca.zip
Merging upstream version 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)