forked from palantir/python-language-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_hover.py
More file actions
68 lines (48 loc) · 1.82 KB
/
test_hover.py
File metadata and controls
68 lines (48 loc) · 1.82 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
56
57
58
59
60
61
62
63
64
65
66
67
68
# Copyright 2017 Palantir Technologies, Inc.
from pyls import uris
from pyls.plugins.hover import pyls_hover
from pyls.workspace import Document
DOC_URI = uris.from_fs_path(__file__)
DOC = """
def main():
\"\"\"hello world\"\"\"
pass
"""
NUMPY_DOC = """
import numpy as np
np.sin
"""
def test_numpy_hover(workspace):
# Over the blank line
no_hov_position = {'line': 1, 'character': 0}
# Over 'numpy' in import numpy as np
numpy_hov_position_1 = {'line': 2, 'character': 8}
# Over 'np' in import numpy as np
numpy_hov_position_2 = {'line': 2, 'character': 17}
# Over 'np' in np.sin
numpy_hov_position_3 = {'line': 3, 'character': 1}
# Over 'sin' in np.sin
numpy_sin_hov_position = {'line': 3, 'character': 4}
doc = Document(DOC_URI, workspace, NUMPY_DOC)
contents = ''
assert contents in pyls_hover(doc, no_hov_position)['contents']
contents = 'NumPy\n=====\n\nProvides\n'
assert contents in pyls_hover(doc, numpy_hov_position_1)['contents'][0]
contents = 'NumPy\n=====\n\nProvides\n'
assert contents in pyls_hover(doc, numpy_hov_position_2)['contents'][0]
contents = 'NumPy\n=====\n\nProvides\n'
assert contents in pyls_hover(doc, numpy_hov_position_3)['contents'][0]
contents = 'Trigonometric sine, element-wise.\n\n'
assert contents in pyls_hover(
doc, numpy_sin_hov_position)['contents'][0]
def test_hover(workspace):
# Over 'main' in def main():
hov_position = {'line': 2, 'character': 6}
# Over the blank second line
no_hov_position = {'line': 1, 'character': 0}
doc = Document(DOC_URI, workspace, DOC)
contents = [{'language': 'python', 'value': 'main()'}, 'hello world']
assert {
'contents': contents
} == pyls_hover(doc, hov_position)
assert {'contents': ''} == pyls_hover(doc, no_hov_position)