Skip to content

Commit a157fc4

Browse files
committed
fea: add walk_up test -> note broken for azure?
1 parent 782d4a2 commit a157fc4

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

upath/implementations/cloud.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def iterdir(self):
5757

5858
def relative_to(self, other, /, *_deprecated, walk_up=False):
5959
# use the parent implementation for the ValueError logic
60-
return super().relative_to(other, *_deprecated, walk_up=False)
60+
return super().relative_to(other, *_deprecated, walk_up=walk_up)
6161

6262

6363
class GCSPath(CloudPath):

upath/tests/implementations/test_azure.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,15 @@ def test_broken_mkdir(self):
6565

6666
def test_relative_to(self):
6767
rel_path = UPath("az:///test_bucket/file.txt").relative_to(UPath("az:///test_bucket"))
68-
6968
assert isinstance(rel_path, PosixUPath)
7069
assert not rel_path.is_absolute()
7170
assert 'file.txt' == rel_path.path
7271

72+
walk_path = UPath("az:///test_bucket/file.txt").relative_to(UPath("az:///other_test_bucket"), walk_up=True)
73+
assert isinstance(walk_path, PosixUPath)
74+
assert not walk_path.is_absolute()
75+
assert '../test_bucket/file.txt' == walk_path.path
76+
7377
with pytest.raises(ValueError):
7478
UPath("az:///test_bucket/file.txt").relative_to(UPath("az:///prod_bucket"))
7579

upath/tests/implementations/test_local.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,23 @@ def test_is_LocalPath(self):
1919

2020
def test_relative_to(self):
2121
rel_path = UPath("file:///test_bucket/file.txt").relative_to(UPath("file:///test_bucket"))
22-
2322
assert isinstance(rel_path, PosixUPath)
2423
assert not rel_path.is_absolute()
2524
assert 'file.txt' == rel_path.path
2625

26+
walk_path = UPath("file:///test_bucket/file.txt").relative_to(UPath("file:///other_test_bucket"), walk_up=True)
27+
assert isinstance(walk_path, PosixUPath)
28+
assert not walk_path.is_absolute()
29+
assert '../test_bucket/file.txt' == walk_path.path
30+
2731
with pytest.raises(ValueError):
2832
UPath("file:///test_bucket/file.txt").relative_to(UPath("file:///prod_bucket"))
2933

3034
with pytest.raises(ValueError):
3135
UPath("file:///test_bucket/file.txt").relative_to(UPath("s3:///test_bucket"))
3236

3337

38+
3439
@skip_on_windows
3540
@xfail_if_version("fsspec", lt="2023.10.0", reason="requires fsspec>=2023.10.0")
3641
class TestRayIOFSSpecLocal(BaseTests):

upath/tests/implementations/test_s3.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,15 @@ def test_rmdir(self):
3939

4040
def test_relative_to(self):
4141
rel_path = UPath("s3:///test_bucket/file.txt").relative_to(UPath("s3:///test_bucket"))
42-
4342
assert isinstance(rel_path, PosixUPath)
4443
assert not rel_path.is_absolute()
4544
assert 'file.txt' == rel_path.path
4645

46+
walk_path = UPath("s3:///test_bucket/file.txt").relative_to(UPath("s3:///other_test_bucket"), walk_up=True)
47+
assert isinstance(walk_path, PosixUPath)
48+
assert not walk_path.is_absolute()
49+
assert '../test_bucket/file.txt' == walk_path.path
50+
4751
with pytest.raises(ValueError):
4852
UPath("s3:///test_bucket/file.txt").relative_to(UPath("s3:///prod_bucket"))
4953

0 commit comments

Comments
 (0)