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