File: test_utils.py

package info (click to toggle)
debputy 0.1.78
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,616 kB
  • sloc: python: 66,232; perl: 155; sh: 102; makefile: 39
file content (21 lines) | stat: -rw-r--r-- 615 bytes parent folder | download | duplicates (2)
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