|
10 | 10 | DOC_URI = uris.from_fs_path(__file__)
|
11 | 11 | DOC = """
|
12 | 12 |
|
13 |
| -def main(): |
| 13 | +def main(a: float, b: float): |
14 | 14 | \"\"\"hello world\"\"\"
|
15 | 15 | pass
|
16 | 16 | """
|
@@ -79,13 +79,36 @@ def test_hover(workspace) -> None:
|
79 | 79 |
|
80 | 80 | doc = Document(DOC_URI, workspace, DOC)
|
81 | 81 |
|
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 | + } |
83 | 86 |
|
84 | 87 | assert {"contents": contents} == pylsp_hover(doc._config, doc, hov_position)
|
85 | 88 |
|
86 | 89 | assert {"contents": ""} == pylsp_hover(doc._config, doc, no_hov_position)
|
87 | 90 |
|
88 | 91 |
|
| 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 | + |
89 | 112 | def test_document_path_hover(workspace_other_root_path, tmpdir) -> None:
|
90 | 113 | # Create a dummy module out of the workspace's root_path and try to get
|
91 | 114 | # a definition on it in another file placed next to it.
|
|
0 commit comments