Skip to content

Commit fb687cf

Browse files
committed
test(analyze): make print-diagnostics path assertions platform-agnostic
The two assertions hardcoded forward-slash paths, which fail on Windows where `_print_diagnostics` renders paths with the native separator (backslash). Build the expected prefix via `Path(...)` so it matches the OS separator on Linux, macOS and Windows alike.
1 parent 3825939 commit fb687cf

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

tests/robotcode/analyze/code/test_print_diagnostics.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ def test_renders_path_severity_code_and_message(self, mocker: MockerFixture, tmp
7777

7878
assert len(lines) == 1
7979
line = lines[0]
80-
assert line.startswith("tests/api/foo.robot:4:5: ")
80+
# Path is rendered with the native separator (backslash on Windows).
81+
assert line.startswith(f"{doc_path}:4:5: ")
8182
# ANSI red, severity label, code, then message.
8283
assert _label(DiagnosticSeverity.ERROR, "KeywordNotFound") in line
8384
assert line.endswith(": boom")
@@ -163,7 +164,7 @@ def test_related_path_is_relative_to_root_when_possible(self, mocker: MockerFixt
163164
Path("doc.robot"),
164165
)
165166

166-
assert "sub/deep.py:1:1:" in lines[1]
167+
assert f"{Path('sub/deep.py')}:1:1:" in lines[1]
167168

168169
def test_related_message_trimmed_by_default(self, mocker: MockerFixture, tmp_path: Path) -> None:
169170
app, lines = _capture(mocker)

0 commit comments

Comments
 (0)