1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
from typing import Union
from collections.abc import Sequence
import pytest
from debputy.util import escape_shell
@pytest.mark.parametrize(
"arg,expected",
[
("foo bar", '"foo bar"'),
("a'b", r"""a\'b"""),
("foo=bar and baz", 'foo="bar and baz"'),
("--foo=bar and baz", '--foo="bar and baz"'),
("--foo with spaces=bar and baz", '"--foo with spaces=bar and baz"'),
],
)
def test_symlink_normalization(arg: str | Sequence[str], expected: str) -> None:
actual = escape_shell(arg) if isinstance(arg, str) else escape_shell(*arg)
assert actual == expected
|