Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix UPath.as_uri() #133

Merged
merged 2 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions upath/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,9 @@ def parents(self) -> _UPathParents:
"""A sequence of this upath's logical parents."""
return _UPathParents(self)

def as_uri(self) -> str:
return str(self)


class _UPathParents(Sequence[UPath]):
"""This object provides sequence-like access to the logical ancestors
Expand Down
9 changes: 8 additions & 1 deletion upath/tests/cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,4 +408,11 @@ def test_private_url_attr_in_sync(self):
p1 = self.path.joinpath("c")
p2 = self.path / "c"
assert p1._url == p2._url
assert p1 != p._url
assert p1._url != p._url

def test_as_uri(self):
# test that we can reconstruct the path from the uri
p0 = self.path
uri = p0.as_uri()
p1 = UPath(uri, **p0.fs.storage_options)
assert p0 == p1