Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
normanrz committed Mar 18, 2022
1 parent 65a6568 commit 14f124d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
5 changes: 2 additions & 3 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from pathlib import Path

import nox
from pathlib import Path


@nox.session(python=False)
Expand Down Expand Up @@ -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)
Expand Down
23 changes: 10 additions & 13 deletions upath/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 10 additions & 0 deletions upath/tests/cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 14f124d

Please sign in to comment.