Пример #1
0
    def test_valid_abs_path_with_dots(self, tmp_path):
        rel_path = pathlib.PurePath("e/./f/g/h/../i/..")
        abs_path = (tmp_path / rel_path).resolve()
        abs_path.mkdir(parents=True)

        path = Path("/" / rel_path, None)
        path.resolve_path(tmp_path)

        assert pathlib.PurePath("e/f/g") == path.data
Пример #2
0
    def test_valid_rel_path_with_dots(self, tmp_path):
        rel_path = pathlib.PurePath("a/././b/../c/../d")
        abs_path = (tmp_path / rel_path).resolve()
        abs_path.mkdir(parents=True)

        path = Path(rel_path, None)
        path.resolve_path(tmp_path)

        assert pathlib.PurePath("a/d") == path.data
Пример #3
0
    def test_valid_dir_path(self, tmp_path):
        rel_path = pathlib.PurePath("some/folder")
        abs_path = tmp_path / rel_path
        abs_path.mkdir(parents=True)

        path = Path(rel_path, None)
        path.resolve_path(tmp_path)

        assert rel_path == path.data
Пример #4
0
    def test_valid_file_path(self, tmp_path):
        rel_path = pathlib.PurePath("some/file.txt")
        abs_path = tmp_path / rel_path
        abs_path.parent.mkdir(parents=True)
        abs_path.write_text("sample_text")

        path = Path(rel_path, None)
        path.resolve_path(tmp_path)

        assert rel_path == path.data