Skip to content

Commit 0a3113e

Browse files
committed
Add a test
1 parent 04cdb98 commit 0a3113e

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

Diff for: test/plugins/test_hover.py

+25-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
DOC_URI = uris.from_fs_path(__file__)
1111
DOC = """
1212
13-
def main():
13+
def main(a: float, b: float):
1414
\"\"\"hello world\"\"\"
1515
pass
1616
"""
@@ -79,13 +79,36 @@ def test_hover(workspace) -> None:
7979

8080
doc = Document(DOC_URI, workspace, DOC)
8181

82-
contents = {"kind": "markdown", "value": "```python\nmain()\n```\n\n\nhello world"}
82+
contents = {
83+
"kind": "markdown",
84+
"value": "```python\nmain(a: float, b: float)\n```\n\n\nhello world",
85+
}
8386

8487
assert {"contents": contents} == pylsp_hover(doc._config, doc, hov_position)
8588

8689
assert {"contents": ""} == pylsp_hover(doc._config, doc, no_hov_position)
8790

8891

92+
def test_hover_custom_signature(workspace) -> None:
93+
# Over 'main' in def main():
94+
hov_position = {"line": 2, "character": 6}
95+
96+
doc = Document(DOC_URI, workspace, DOC)
97+
98+
contents = {
99+
"kind": "markdown",
100+
"value": "```python\nmain(\n a: float,\n b: float\n)\n```\n\n\nhello world",
101+
}
102+
103+
def signatures_to_markdown(signatures: list):
104+
# dummy implementation for tests
105+
return "```python\nmain(\n a: float,\n b: float\n)\n```\n"
106+
107+
assert {"contents": contents} == pylsp_hover(
108+
doc._config, doc, hov_position, signatures_to_markdown=signatures_to_markdown
109+
)
110+
111+
89112
def test_document_path_hover(workspace_other_root_path, tmpdir) -> None:
90113
# Create a dummy module out of the workspace's root_path and try to get
91114
# a definition on it in another file placed next to it.

0 commit comments

Comments
 (0)