@@ -185,3 +185,51 @@ def test_pickling_child_path():
185185 assert path ._root == recovered_path ._root
186186 assert path ._parts == recovered_path ._parts
187187 assert path .fs .storage_options == recovered_path .fs .storage_options
188+
189+
190+ def test_copy_path ():
191+ path = UPath ("gcs://bucket/folder" , anon = True )
192+ copy_path = UPath (path )
193+
194+ print (type (path ), type (copy_path ))
195+
196+ assert type (path ) == type (copy_path )
197+ assert str (path ) == str (copy_path )
198+ assert path ._drv == copy_path ._drv
199+ assert path ._root == copy_path ._root
200+ assert path ._parts == copy_path ._parts
201+ assert path .fs .storage_options == copy_path .fs .storage_options
202+
203+
204+ def test_copy_path_posix ():
205+ path = UPath ("/tmp/folder" )
206+ copy_path = UPath (path )
207+
208+ assert type (path ) == type (copy_path ) == type (pathlib .Path ("" ))
209+ assert str (path ) == str (copy_path )
210+ assert path ._drv == copy_path ._drv
211+ assert path ._root == copy_path ._root
212+ assert path ._parts == copy_path ._parts
213+
214+
215+ def test_copy_path_append ():
216+ path = UPath ("/tmp/folder" )
217+ copy_path = UPath (path , "folder2" )
218+
219+ assert type (path ) == type (copy_path ) == type (pathlib .Path ("" ))
220+ assert str (path / "folder2" ) == str (copy_path )
221+
222+ path = UPath ("/tmp/folder" )
223+ copy_path = UPath (path , "folder2/folder3" )
224+
225+ assert str (path / "folder2" / "folder3" ) == str (copy_path )
226+
227+
228+ def test_copy_path_append_kwargs ():
229+ path = UPath ("gcs://bucket/folder" , anon = True )
230+ copy_path = UPath (path , anon = False )
231+
232+ assert type (path ) == type (copy_path )
233+ assert str (path ) == str (copy_path )
234+ assert not copy_path ._kwargs ["anon" ]
235+ assert path ._kwargs ["anon" ]
0 commit comments