Skip to content

Commit 14f124d

Browse files
committed
fixes
1 parent 65a6568 commit 14f124d

File tree

3 files changed

+22
-16
lines changed

3 files changed

+22
-16
lines changed

noxfile.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
from pathlib import Path
2-
31
import nox
2+
from pathlib import Path
43

54

65
@nox.session(python=False)
@@ -29,7 +28,7 @@ def install(session):
2928
@nox.session(python=False)
3029
def smoke(session):
3130
session.install(*"pytest aiohttp requests gcsfs".split())
32-
session.run(*"pytest --skiphdfs -vv -s upath".split())
31+
session.run(*"pytest --skiphdfs -vv upath".split())
3332

3433

3534
@nox.session(python=False)

upath/core.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -327,19 +327,16 @@ def _from_parsed_parts(self, drv, root, parts, init=True):
327327
return obj
328328

329329
def __truediv__(self, key):
330-
try:
331-
if len(self._parts) == 0:
332-
key = f"/{key}"
333-
out = self._make_child((key,))
334-
kwargs = out._kwargs.copy()
335-
kwargs.pop("_url")
336-
out = out.__class__(
337-
out._format_parsed_parts(out._drv, out._root, out._parts),
338-
**kwargs,
339-
)
340-
return out
341-
except TypeError:
342-
return NotImplemented
330+
if len(self._parts) == 0:
331+
key = f"{self._root}{key}"
332+
out = self._make_child((key,))
333+
kwargs = out._kwargs.copy()
334+
kwargs.pop("_url")
335+
out = out.__class__(
336+
out._format_parsed_parts(out._drv, out._root, out._parts),
337+
**kwargs,
338+
)
339+
return out
343340

344341
def __setstate__(self, state):
345342
kwargs = state["_kwargs"].copy()

upath/tests/cases.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,3 +249,13 @@ def test_pickling_child_path(self):
249249
assert path._root == recovered_path._root
250250
assert path._parts == recovered_path._parts
251251
assert path.fs.storage_options == recovered_path.fs.storage_options
252+
253+
def test_child_path(self):
254+
path_a = UPath(f"{self.path}/folder")
255+
path_b = self.path / "folder"
256+
257+
assert str(path_a) == str(path_b)
258+
assert path_a._root == path_b._root
259+
assert path_a._drv == path_b._drv
260+
assert path_a._parts == path_b._parts
261+
assert path_a._url == path_b._url

0 commit comments

Comments
 (0)