Skip to content

Commit b01b9fc

Browse files
committed
externalize testdata for hover tests
1 parent b164810 commit b01b9fc

File tree

2 files changed

+25
-13
lines changed

2 files changed

+25
-13
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
*** Settings ***
2+
Library Collections
3+
4+
*** Variables ***
5+
${A VAR} i'm a var
6+
&{A DICT} a=1 b=2 c=3
7+
8+
*** Test Cases ***
9+
first
10+
Log Hello ${A VAR}
11+
Collections.Log Dictionary ${A DICT}
12+
FOR ${key} ${value} IN &{A DICT}
13+
Log ${key}=${value}
14+
END

tests/robotcode/language_server/robotframework/parts/test_hover.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,18 @@ async def protocol() -> AsyncGenerator[RobotLanguageServerProtocol, None]:
4646

4747
@pytest.fixture
4848
async def test_document() -> AsyncGenerator[TextDocument, None]:
49-
data = """\
50-
***Test Cases***
51-
first
52-
Log Hello
53-
"""
54-
yield TextDocument(document_uri="file:///test.robot", language_id="robotframework", version=1, text=data)
49+
data_path = Path(Path(__file__).parent, "data/hover.robot")
50+
data = data_path.read_text()
51+
52+
yield TextDocument(document_uri=data_path.as_uri(), language_id="robotframework", version=1, text=data)
5553

5654

5755
@pytest.mark.parametrize(
5856
("position",),
5957
[
60-
(Position(line=2, character=4),),
61-
(Position(line=2, character=5),),
62-
(Position(line=2, character=6),),
58+
(Position(line=9, character=4),),
59+
(Position(line=9, character=5),),
60+
(Position(line=9, character=6),),
6361
],
6462
)
6563
@pytest.mark.asyncio
@@ -69,17 +67,17 @@ async def test_hover_should_find_simple_keyword(
6967

7068
result = await protocol._robot_hover.collect(protocol.hover, test_document, position)
7169
assert result
72-
assert result.range == Range(start=Position(line=2, character=4), end=Position(line=2, character=7))
70+
assert result.range == Range(start=Position(line=9, character=4), end=Position(line=9, character=7))
7371
assert isinstance(result.contents, MarkupContent)
7472
assert result.contents.kind == MarkupKind.MARKDOWN
75-
assert "Log" in result.contents.value
73+
assert result.contents.value.startswith("#### Log")
7674

7775

7876
@pytest.mark.parametrize(
7977
("position",),
8078
[
81-
(Position(line=2, character=3),),
82-
(Position(line=2, character=7),),
79+
(Position(line=9, character=3),),
80+
(Position(line=9, character=7),),
8381
],
8482
)
8583
@pytest.mark.asyncio

0 commit comments

Comments
 (0)