-
Notifications
You must be signed in to change notification settings - Fork 233
Expand file tree
/
Copy pathtest_workspace_symbols.py
More file actions
55 lines (38 loc) · 1.05 KB
/
test_workspace_symbols.py
File metadata and controls
55 lines (38 loc) · 1.05 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
54
55
# Copyright 2017-2020 Palantir Technologies, Inc.
# Copyright 2021- Python Language Server Contributors.
import os
import sys
import pytest
from pylsp import uris
from pylsp.plugins.workspace_symbol import pylsp_workspace_symbol
PY2 = sys.version[0] == "2"
LINUX = sys.platform.startswith("linux")
CI = os.environ.get("CI")
DOC_URI = uris.from_fs_path(__file__)
DOC1_NAME = "file1.py"
DOC2_NAME = "file2.py"
DOC1 = """class Test1():
pass
"""
DOC2 = """from file1 import Test1
try:
Test1()
except UnicodeError:
pass
"""
@pytest.fixture
def tmp_workspace(temp_workspace_factory):
return temp_workspace_factory(
{
DOC1_NAME: DOC1,
DOC2_NAME: DOC2,
}
)
def test_symbols_empty_query(tmp_workspace):
symbols = pylsp_workspace_symbol(tmp_workspace, "")
assert len(symbols) == 0
def test_symbols_nonempty_query(tmp_workspace):
symbols = pylsp_workspace_symbol(tmp_workspace, "Test")
assert len(symbols) == 1
assert symbols[0]["name"] == "Test1"
assert symbols[0]["kind"] == 5 # Class