Skip to content

Commit 2d307c5

Browse files
committed
add tests
1 parent b8f544e commit 2d307c5

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test/plugins/test_symbols.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,17 @@ def main(x):
3030
3131
"""
3232

33+
DOC_IMPORTS = """from . import something
34+
from ..module import something
35+
from module import (a, b)
36+
37+
def main():
38+
# import ignored
39+
print("from module import x") # string with import
40+
return something
41+
42+
"""
43+
3344

3445
def helper_check_symbols_all_scope(symbols):
3546
# All eight symbols (import sys, a, B, __init__, x, y, main, y)
@@ -73,6 +84,22 @@ def sym(name):
7384
assert sym("main")["location"]["range"]["end"] == {"line": 12, "character": 0}
7485

7586

87+
def test_symbols_complex_imports(config, workspace):
88+
doc = Document(DOC_URI, workspace, DOC_IMPORTS)
89+
config.update({"plugins": {"jedi_symbols": {"all_scopes": False}}})
90+
symbols = pylsp_document_symbols(config, doc)
91+
92+
import_symbols = [s for s in symbols if s["kind"] == SymbolKind.Module]
93+
94+
assert len(import_symbols) == 4
95+
96+
names = [s["name"] for s in import_symbols]
97+
assert "something" in names
98+
assert "a" in names or "b" in names
99+
100+
assert any(s["name"] == "main" and s["kind"] == SymbolKind.Function for s in symbols)
101+
102+
76103
def test_symbols_all_scopes(config, workspace) -> None:
77104
doc = Document(DOC_URI, workspace, DOC)
78105
symbols = pylsp_document_symbols(config, doc)

0 commit comments

Comments
 (0)