Skip to content

Commit 3dafb64

Browse files
cursoragentPuritanWizard
andcommitted
test(common): cover diff cli_utils path normalization
Co-authored-by: PuritanWizard <th3w1zard1@users.noreply.github.com>
1 parent d69a7a6 commit 3dafb64

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"""Regression tests for diff_tool.cli_utils path normalization."""
2+
3+
from __future__ import annotations
4+
5+
import pytest
6+
7+
from pykotor.diff_tool.cli_utils import normalize_path_arg
8+
9+
10+
@pytest.mark.parametrize(
11+
("raw", "expected"),
12+
[
13+
(None, None),
14+
("", None),
15+
(" ", None),
16+
("/tmp/kotor", "/tmp/kotor"),
17+
('"/tmp/kotor"', "/tmp/kotor"),
18+
("'/tmp/kotor'", "/tmp/kotor"),
19+
(r'C:\Games\KOTOR\ ', r"C:\Games\KOTOR"),
20+
(r'C:\Games\KOTOR\" C:\Other', r"C:\Games\KOTOR"),
21+
],
22+
)
23+
def test_normalize_path_arg_strips_quotes_and_whitespace(
24+
raw: str | None,
25+
expected: str | None,
26+
) -> None:
27+
assert normalize_path_arg(raw) == expected
28+
29+
30+
def test_normalize_path_arg_removes_embedded_quotes() -> None:
31+
assert normalize_path_arg('C:\\"Games\\"KOTOR') == r"C:\Games\KOTOR"

0 commit comments

Comments
 (0)