File tree Expand file tree Collapse file tree 4 files changed +23
-1
lines changed
Expand file tree Collapse file tree 4 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,12 @@ def iterdir(self) -> Iterator[Self]:
4444 @property
4545 def path (self ) -> str :
4646 path = super ().path
47- return "/" if path == "." else path
47+ return "/" if path in {"" , "." } else path
48+
49+ def is_absolute (self ) -> bool :
50+ if self ._relative_base is None and self .__vfspath__ () == "/" :
51+ return True
52+ return super ().is_absolute ()
4853
4954 def __str__ (self ) -> str :
5055 s = super ().__str__ ()
Original file line number Diff line number Diff line change @@ -782,3 +782,9 @@ def test_trailing_slash_is_stripped(self):
782782 else :
783783 assert not self .path .joinpath ("key" ).path .endswith ("/" )
784784 assert not self .path .joinpath ("key/" ).path .endswith ("/" )
785+
786+ def test_parents_are_absolute (self ):
787+ # this is a cross implementation compatible way to ensure that
788+ # the path representing the root is absolute
789+ is_absolute = [p .is_absolute () for p in self .path .parents ]
790+ assert all (is_absolute )
Original file line number Diff line number Diff line change @@ -300,3 +300,7 @@ def test_trailing_slash_joinpath_is_identical(self):
300300 @pytest .mark .skip (reason = "DataPath does not support joins" )
301301 def test_trailing_slash_is_stripped (self ):
302302 pass
303+
304+ @pytest .mark .skip (reason = "DataPath does not support joins" )
305+ def test_parents_are_absolute (self ):
306+ pass
Original file line number Diff line number Diff line change @@ -79,6 +79,13 @@ def test_iterdir_no_dir(self):
7979 # so this test would need to have an iterdir fix.
8080 super ().test_iterdir_no_dir ()
8181
82+ @pytest .mark .skipif (
83+ sys .platform .startswith ("win" ),
84+ reason = "mock fs is not well defined on windows" ,
85+ )
86+ def test_parents_are_absolute (self ):
87+ return super ().test_parents_are_absolute ()
88+
8289
8390def test_multiple_backend_paths (local_testdir ):
8491 path = "s3://bucket/"
You can’t perform that action at this time.
0 commit comments