Exemplo n.º 1
0
import collections
import pathlib
import typing
import unittest

import hypothesis
import hypothesis.strategies
from eden.cli.systemd import (
    SystemdEnvironmentFile,
    escape_dbus_address,
    systemd_escape_path,
)
from eden.test_support.hypothesis import fast_hypothesis_test, set_up_hypothesis

set_up_hypothesis()


class SystemdEscapeTest(unittest.TestCase):
    def test_escape_benign_absolute_path(self) -> None:
        self.assertEqual(
            systemd_escape_path(pathlib.PurePosixPath("/path/to/file.txt")),
            "path-to-file.txt",
        )

    def test_escape_path_containing_funky_characters(self) -> None:
        self.assertEqual(
            systemd_escape_path(pathlib.PurePosixPath("/file with spaces")),
            r"file\x20with\x20spaces",
        )
        self.assertEqual(
Exemplo n.º 2
0
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.

import collections
import pathlib
import typing
import unittest

import hypothesis
import hypothesis.strategies
from eden.cli.systemd import SystemdEnvironmentFile, systemd_escape_path
from eden.test_support.hypothesis import fast_hypothesis_test, set_up_hypothesis


set_up_hypothesis()


class SystemdEscapeTest(unittest.TestCase):
    def test_escape_benign_absolute_path(self) -> None:
        self.assertEqual(
            systemd_escape_path(pathlib.PurePosixPath("/path/to/file.txt")),
            "path-to-file.txt",
        )

    def test_escape_path_containing_funky_characters(self) -> None:
        self.assertEqual(
            systemd_escape_path(pathlib.PurePosixPath("/file with spaces")),
            r"file\x20with\x20spaces",
        )
        self.assertEqual(