@@ -376,6 +376,40 @@ def test_read_infer(self, ext, get_random_path):
376
376
377
377
tm .assert_frame_equal (df , df2 )
378
378
379
+ @pytest .mark .parametrize ("cruft" , ["__MACOSX/" , ".DS_STORE" ])
380
+ def test_load_zip_with_hidden_folders (self , cruft , get_random_path ):
381
+ """Test loading .zip files that have extraneous metadata in hidden folders. """
382
+ base = get_random_path
383
+ path1 = base + ".raw"
384
+ path2 = base + ".zip"
385
+ dummy = base + ".dummy"
386
+ compression = "zip"
387
+
388
+ with tm .ensure_clean (path1 ) as p1 , tm .ensure_clean (
389
+ path2
390
+ ) as p2 , tm .ensure_clean (dummy ) as d :
391
+ df = tm .makeDataFrame ()
392
+
393
+ # write to uncompressed file
394
+ df .to_pickle (p1 , compression = None )
395
+
396
+ # compress dataframe normally
397
+ self .compress_file (p1 , p2 , compression = compression )
398
+
399
+ # add dummy file `{cruft}{dummy}` to the archive
400
+ with zipfile .ZipFile (p2 , "a" , compression = zipfile .ZIP_DEFLATED ) as f :
401
+ f .write (d , f"{ cruft } { dummy } " )
402
+
403
+ # check the file was definitely added to the archive
404
+ with zipfile .ZipFile (p2 , "r" ) as f :
405
+ assert f"{ cruft } { dummy } " in f .namelist ()
406
+
407
+ # compressed file by inferred compression method,
408
+ # dummy file should have been ignored
409
+ df2 = pd .read_pickle (p2 )
410
+
411
+ tm .assert_frame_equal (df , df2 )
412
+
379
413
380
414
# ---------------------
381
415
# test pickle compression
0 commit comments