From a236ed26adac1c0f0826316bf18287d635d29efd Mon Sep 17 00:00:00 2001 From: Andreas Poehlmann Date: Sun, 20 Aug 2023 22:28:09 +0200 Subject: [PATCH 1/2] tests: add uri test --- upath/tests/cases.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/upath/tests/cases.py b/upath/tests/cases.py index ba0fbcb8..b48499c4 100644 --- a/upath/tests/cases.py +++ b/upath/tests/cases.py @@ -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 From 1da137b7d67e8a6dcb50c99187f4b27166e15c44 Mon Sep 17 00:00:00 2001 From: Andreas Poehlmann Date: Sun, 20 Aug 2023 22:28:38 +0200 Subject: [PATCH 2/2] upath: fix as_uri --- upath/core.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/upath/core.py b/upath/core.py index 9e07e8db..e35425d4 100644 --- a/upath/core.py +++ b/upath/core.py @@ -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