Skip to content

Commit e4ec937

Browse files
committed
Fix tests
1 parent 66fe88d commit e4ec937

File tree

4 files changed

+78
-3
lines changed

4 files changed

+78
-3
lines changed

pylsp/hookspecs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def pylsp_execute_command(config, workspace, command, arguments):
6969

7070

7171
@hookspec
72-
def pylsp_workspace_symbol(config, workspace, document, query):
72+
def pylsp_workspace_symbol(config, workspace, query):
7373
pass
7474

7575

pylsp/plugins/workspace_symbol.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313
@hookimpl
14-
def pylsp_workspace_symbol(config, workspace, document, query):
14+
def pylsp_workspace_symbol(config, workspace, query):
1515
if not query or not workspace:
1616
return []
1717

test/plugins/test_symbols.py renamed to test/plugins/test_document_symbols.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from pylsp import uris
1010
from pylsp.lsp import SymbolKind
1111
from pylsp.plugins.document_symbols import pylsp_document_symbols
12-
from pylsp.plugins.workspace_symbol import pylsp_workspace_symbol
1312
from pylsp.workspace import Document
1413

1514
PY2 = sys.version[0] == "2"
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Copyright 2017-2020 Palantir Technologies, Inc.
2+
# Copyright 2021- Python Language Server Contributors.
3+
4+
import os
5+
import sys
6+
7+
import pytest
8+
9+
from pylsp import uris
10+
from pylsp.lsp import SymbolKind
11+
from pylsp.plugins.workspace_symbol import pylsp_workspace_symbol
12+
from pylsp.workspace import Workspace
13+
14+
PY2 = sys.version[0] == "2"
15+
LINUX = sys.platform.startswith("linux")
16+
CI = os.environ.get("CI")
17+
DOC_URI = uris.from_fs_path(__file__)
18+
DOC = """import sys
19+
20+
a = 'hello'
21+
22+
class B:
23+
def __init__(self):
24+
x = 2
25+
self.y = x
26+
27+
def main(x):
28+
y = 2 * x
29+
return y
30+
31+
"""
32+
33+
34+
def test_symbols_empty_query(config, workspace):
35+
config.update({"plugins": {"jedi_workspace_symbols": {"enabled": True}}})
36+
symbols = pylsp_workspace_symbol(config, workspace, "")
37+
38+
assert len(symbols) == 0
39+
40+
41+
def test_symbols_nonempty_query(config, workspace):
42+
config.update({"plugins": {"jedi_workspace_symbols": {"enabled": True}}})
43+
symbols = pylsp_workspace_symbol(config, workspace, "main")
44+
45+
assert len(symbols) == 0
46+
47+
48+
#
49+
# def test_symbols_all_scopes(config, workspace):
50+
# doc = Document(DOC_URI, workspace, DOC)
51+
# symbols = pylsp_document_symbols(config, doc)
52+
# helper_check_symbols_all_scope(symbols)
53+
#
54+
#
55+
# def test_symbols_non_existing_file(config, workspace, tmpdir):
56+
# path = tmpdir.join("foo.py")
57+
# # Check pre-condition: file must not exist
58+
# assert not path.check(exists=1)
59+
#
60+
# doc = Document(uris.from_fs_path(str(path)), workspace, DOC)
61+
# symbols = pylsp_document_symbols(config, doc)
62+
# helper_check_symbols_all_scope(symbols)
63+
#
64+
#
65+
# @pytest.mark.skipif(
66+
# PY2 or not LINUX or not CI, reason="tested on linux and python 3 only"
67+
# )
68+
# def test_symbols_all_scopes_with_jedi_environment(workspace):
69+
# doc = Document(DOC_URI, workspace, DOC)
70+
#
71+
# # Update config extra environment
72+
# env_path = "/tmp/pyenv/bin/python"
73+
# settings = {"pylsp": {"plugins": {"jedi": {"environment": env_path}}}}
74+
# doc.update_config(settings)
75+
# symbols = pylsp_document_symbols(doc._config, doc)
76+
# helper_check_symbols_all_scope(symbols)

0 commit comments

Comments
 (0)