@@ -176,3 +176,51 @@ def test_pickling_child_path():
176176 assert path ._root == recovered_path ._root
177177 assert path ._parts == recovered_path ._parts
178178 assert path .fs .storage_options == recovered_path .fs .storage_options
179+
180+
181+ def test_copy_path ():
182+ path = UPath ("gcs://bucket/folder" , anon = True )
183+ copy_path = UPath (path )
184+
185+ print (type (path ), type (copy_path ))
186+
187+ assert type (path ) == type (copy_path )
188+ assert str (path ) == str (copy_path )
189+ assert path ._drv == copy_path ._drv
190+ assert path ._root == copy_path ._root
191+ assert path ._parts == copy_path ._parts
192+ assert path .fs .storage_options == copy_path .fs .storage_options
193+
194+
195+ def test_copy_path_posix ():
196+ path = UPath ("/tmp/folder" )
197+ copy_path = UPath (path )
198+
199+ assert type (path ) == type (copy_path ) == type (pathlib .Path ("" ))
200+ assert str (path ) == str (copy_path )
201+ assert path ._drv == copy_path ._drv
202+ assert path ._root == copy_path ._root
203+ assert path ._parts == copy_path ._parts
204+
205+
206+ def test_copy_path_append ():
207+ path = UPath ("/tmp/folder" )
208+ copy_path = UPath (path , "folder2" )
209+
210+ assert type (path ) == type (copy_path ) == type (pathlib .Path ("" ))
211+ assert str (path / "folder2" ) == str (copy_path )
212+
213+ path = UPath ("/tmp/folder" )
214+ copy_path = UPath (path , "folder2/folder3" )
215+
216+ assert str (path / "folder2" / "folder3" ) == str (copy_path )
217+
218+
219+ def test_copy_path_append_kwargs ():
220+ path = UPath ("gcs://bucket/folder" , anon = True )
221+ copy_path = UPath (path , anon = False )
222+
223+ assert type (path ) == type (copy_path )
224+ assert str (path ) == str (copy_path )
225+ assert not copy_path ._kwargs ["anon" ]
226+ assert path ._kwargs ["anon" ]
0 commit comments