@@ -382,14 +382,23 @@ def test_read(self, protocol, get_random_path):
382
382
tm .assert_frame_equal (df , df2 )
383
383
384
384
385
- def test_unicode_decode_error (datapath ):
385
+ @pytest .mark .parametrize (
386
+ ["pickle_file" , "excols" ],
387
+ [
388
+ ("test_py27.pkl" , pd .Index (["a" , "b" , "c" ])),
389
+ (
390
+ "test_mi_py27.pkl" ,
391
+ pd .MultiIndex .from_arrays ([["a" , "b" , "c" ], ["A" , "B" , "C" ]]),
392
+ ),
393
+ ],
394
+ )
395
+ def test_unicode_decode_error (datapath , pickle_file , excols ):
386
396
# pickle file written with py27, should be readable without raising
387
- # UnicodeDecodeError, see GH#28645
388
- path = datapath ("io" , "data" , "pickle" , "test_py27.pkl" )
397
+ # UnicodeDecodeError, see GH#28645 and GH#31988
398
+ path = datapath ("io" , "data" , "pickle" , pickle_file )
389
399
df = pd .read_pickle (path )
390
400
391
401
# just test the columns are correct since the values are random
392
- excols = pd .Index (["a" , "b" , "c" ])
393
402
tm .assert_index_equal (df .columns , excols )
394
403
395
404
@@ -501,15 +510,3 @@ def test_read_pickle_with_subclass():
501
510
502
511
tm .assert_series_equal (result [0 ], expected [0 ])
503
512
assert isinstance (result [1 ], MyTz )
504
-
505
-
506
- def test_read_py27_pickle_with_MultiIndex_column (datapath ):
507
- # pickle file with MultiIndex column written with py27
508
- # should be readable without raising UnicodeDecodeError
509
- # see GH#31988
510
- path = datapath ("io" , "data" , "pickle" , "test_mi_py27.pkl" )
511
- df = pd .read_pickle (path )
512
-
513
- # just test the columns are correct since the values are random
514
- expected = pd .MultiIndex .from_arrays ([["a" , "b" , "c" ], ["A" , "B" , "C" ]])
515
- tm .assert_index_equal (df .columns , expected )
0 commit comments