Skip to content

Commit bbc3c3d

Browse files
authored
Fix UPath.as_uri() (#133)
* tests: add uri test * upath: fix as_uri
1 parent 9ce4a9a commit bbc3c3d

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

upath/core.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,9 @@ def parents(self) -> _UPathParents:
722722
"""A sequence of this upath's logical parents."""
723723
return _UPathParents(self)
724724

725+
def as_uri(self) -> str:
726+
return str(self)
727+
725728

726729
class _UPathParents(Sequence[UPath]):
727730
"""This object provides sequence-like access to the logical ancestors

upath/tests/cases.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,4 +408,11 @@ def test_private_url_attr_in_sync(self):
408408
p1 = self.path.joinpath("c")
409409
p2 = self.path / "c"
410410
assert p1._url == p2._url
411-
assert p1 != p._url
411+
assert p1._url != p._url
412+
413+
def test_as_uri(self):
414+
# test that we can reconstruct the path from the uri
415+
p0 = self.path
416+
uri = p0.as_uri()
417+
p1 = UPath(uri, **p0.fs.storage_options)
418+
assert p0 == p1

0 commit comments

Comments
 (0)