@@ -66,6 +66,18 @@ def test_write_seek(m):
6666 assert fs .cat ("another" ) == b"hi"
6767
6868
69+ @pytest .mark .parametrize ("prefix" , ["" , "/" , "zip://" , "zip:///" ])
70+ def test_pipe_file_normalizes_path (m , prefix ):
71+ fs = fsspec .filesystem ("zip" , fo = "memory://out.zip" , mode = "w" )
72+ fs .pipe_file (f"{ prefix } reports/result.csv" , b"total\n 12\n " )
73+ fs .close ()
74+
75+ fs = fsspec .filesystem ("zip" , fo = "memory://out.zip" )
76+ assert fs .find ("" ) == ["reports/result.csv" ]
77+ assert fs .cat ("reports/result.csv" ) == b"total\n 12\n "
78+ fs .close ()
79+
80+
6981def test_rw (m ):
7082 # extra arg to zip means "create archive"
7183 with fsspec .open (
@@ -457,13 +469,15 @@ def test_find_returns_expected_result_detail_false_include_dirs(zip_file):
457469 assert result == expected_result
458470
459471
460- def test_find_returns_expected_result_path_set (zip_file ):
472+ @pytest .mark .parametrize ("prefix" , ["/" , "zip://" , "zip:///" ])
473+ @pytest .mark .parametrize ("detail" , [False , True ])
474+ def test_find_returns_expected_result_path_set (zip_file , prefix , detail ):
461475 zip_file_system = ZipFileSystem (zip_file )
462476
463- result = zip_file_system .find ("/ dir2" )
477+ result = zip_file_system .find (f" { prefix } dir2", detail = detail )
464478 expected_result = ["dir2/file3.txt" ]
465479
466- assert result == expected_result
480+ assert list ( result ) == expected_result
467481
468482
469483def test_find_with_and_without_slash_should_return_same_result (zip_file ):
@@ -472,10 +486,11 @@ def test_find_with_and_without_slash_should_return_same_result(zip_file):
472486 assert zip_file_system .find ("/dir2/" ) == zip_file_system .find ("/dir2" )
473487
474488
475- def test_find_should_return_file_if_exact_match (zip_file ):
489+ @pytest .mark .parametrize ("prefix" , ["/" , "zip://" , "zip:///" ])
490+ def test_find_should_return_file_if_exact_match (zip_file , prefix ):
476491 zip_file_system = ZipFileSystem (zip_file )
477492
478- result = zip_file_system .find ("/ dir2startwithsamename.txt" , detail = False )
493+ result = zip_file_system .find (f" { prefix } dir2startwithsamename.txt" , detail = False )
479494 expected_result = ["dir2startwithsamename.txt" ]
480495
481496 assert result == expected_result
0 commit comments