Skip to content

UPath.rename should raise on relative paths if no .cwd() is implemented #479

@ap--

Description

@ap--

This is currently incorrectly implemented and incorrectly checked in the tests.

def test_rename2(self):
upath = self.path.joinpath("folder1/file2.txt")
target = "file2_renamed.txt"
moved = upath.rename(target)
target_path = upath.parent.joinpath(target).resolve()
assert target_path == moved
assert not upath.exists()
assert moved.exists()
# reverse with a relative path as UPath
back = moved.rename(UPath("file2.txt"))
assert back == upath
assert not moved.exists()
assert back.exists()

def rename(

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions