Skip to content

Commit 1a89f63

Browse files
committed
parametrize test
1 parent bcf41c9 commit 1a89f63

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

Diff for: pandas/tests/io/test_pickle.py

+13-16
Original file line numberDiff line numberDiff line change
@@ -382,14 +382,23 @@ def test_read(self, protocol, get_random_path):
382382
tm.assert_frame_equal(df, df2)
383383

384384

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):
386396
# 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)
389399
df = pd.read_pickle(path)
390400

391401
# just test the columns are correct since the values are random
392-
excols = pd.Index(["a", "b", "c"])
393402
tm.assert_index_equal(df.columns, excols)
394403

395404

@@ -501,15 +510,3 @@ def test_read_pickle_with_subclass():
501510

502511
tm.assert_series_equal(result[0], expected[0])
503512
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

Comments
 (0)