diff --git a/noxfile.py b/noxfile.py index 838bb6e7..24e12349 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,6 +1,5 @@ -from pathlib import Path - import nox +from pathlib import Path @nox.session(python=False) @@ -29,7 +28,7 @@ def install(session): @nox.session(python=False) def smoke(session): session.install(*"pytest aiohttp requests gcsfs".split()) - session.run(*"pytest --skiphdfs -vv -s upath".split()) + session.run(*"pytest --skiphdfs -vv upath".split()) @nox.session(python=False) diff --git a/upath/core.py b/upath/core.py index 2bcf41d6..fa5c9ba8 100644 --- a/upath/core.py +++ b/upath/core.py @@ -327,19 +327,16 @@ def _from_parsed_parts(self, drv, root, parts, init=True): return obj def __truediv__(self, key): - try: - if len(self._parts) == 0: - key = f"/{key}" - out = self._make_child((key,)) - kwargs = out._kwargs.copy() - kwargs.pop("_url") - out = out.__class__( - out._format_parsed_parts(out._drv, out._root, out._parts), - **kwargs, - ) - return out - except TypeError: - return NotImplemented + if len(self._parts) == 0: + key = f"{self._root}{key}" + out = self._make_child((key,)) + kwargs = out._kwargs.copy() + kwargs.pop("_url") + out = out.__class__( + out._format_parsed_parts(out._drv, out._root, out._parts), + **kwargs, + ) + return out def __setstate__(self, state): kwargs = state["_kwargs"].copy() diff --git a/upath/tests/cases.py b/upath/tests/cases.py index 5782cd77..6968d88b 100644 --- a/upath/tests/cases.py +++ b/upath/tests/cases.py @@ -249,3 +249,13 @@ def test_pickling_child_path(self): assert path._root == recovered_path._root assert path._parts == recovered_path._parts assert path.fs.storage_options == recovered_path.fs.storage_options + + def test_child_path(self): + path_a = UPath(f"{self.path}/folder") + path_b = self.path / "folder" + + assert str(path_a) == str(path_b) + assert path_a._root == path_b._root + assert path_a._drv == path_b._drv + assert path_a._parts == path_b._parts + assert path_a._url == path_b._url