From 952ce864f5a420cf6457bdd2df1a4701897e31dd Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Wed, 5 Jun 2019 09:25:02 -0400 Subject: [PATCH 1/5] Replaced sparsely used frame2 fixture --- pandas/tests/io/test_excel.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/pandas/tests/io/test_excel.py b/pandas/tests/io/test_excel.py index b99f0336fa4c5..31d37b8ed1a82 100644 --- a/pandas/tests/io/test_excel.py +++ b/pandas/tests/io/test_excel.py @@ -32,13 +32,6 @@ def frame(float_frame): return float_frame[:10] -@pytest.fixture -def frame2(float_frame): - float_frame = float_frame.copy() - float_frame.columns = ['D', 'C', 'B', 'A'] - return float_frame[:10] - - @pytest.fixture def tsframe(): return tm.makeTimeDataFrame()[:5] @@ -1149,9 +1142,11 @@ def test_excel_sheet_by_name_raise(self, *_): with pytest.raises(xlrd.XLRDError): pd.read_excel(xl, "0") - def test_excel_writer_context_manager(self, frame, frame2, *_): + def test_excel_writer_context_manager(self, frame, *_): with ExcelWriter(self.path) as writer: frame.to_excel(writer, "Data1") + frame2 = frame.copy() + frame2.columns = frame.columns[::-1] frame2.to_excel(writer, "Data2") with ExcelFile(self.path) as reader: @@ -1318,7 +1313,7 @@ def test_sheets(self, merge_cells, engine, ext, frame, tsframe): assert 'test1' == reader.sheet_names[0] assert 'test2' == reader.sheet_names[1] - def test_colaliases(self, merge_cells, engine, ext, frame, frame2): + def test_colaliases(self, merge_cells, engine, ext, frame): frame = frame.copy() frame['A'][:5] = nan @@ -1329,10 +1324,10 @@ def test_colaliases(self, merge_cells, engine, ext, frame, frame2): # column aliases col_aliases = Index(['AA', 'X', 'Y', 'Z']) - frame2.to_excel(self.path, 'test1', header=col_aliases) + frame.to_excel(self.path, 'test1', header=col_aliases) reader = ExcelFile(self.path) rs = pd.read_excel(reader, 'test1', index_col=0) - xp = frame2.copy() + xp = frame.copy() xp.columns = col_aliases tm.assert_frame_equal(xp, rs) From 620fa19c90a47281ee62ff1d80c05bf46647cd3f Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Wed, 5 Jun 2019 09:38:04 -0400 Subject: [PATCH 2/5] Cleaned up parametrization and xlrd min skips --- pandas/tests/io/test_excel.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pandas/tests/io/test_excel.py b/pandas/tests/io/test_excel.py index 31d37b8ed1a82..6a297969014f3 100644 --- a/pandas/tests/io/test_excel.py +++ b/pandas/tests/io/test_excel.py @@ -51,8 +51,9 @@ def ignore_xlrd_time_clock_warning(): yield -@td.skip_if_no('xlrd', '1.0.0') -class ReadingTestsBase: +@td.skip_if_no('xlrd') +@pytest.mark.parametrize("ext", ['.xls', '.xlsx', '.xlsm']) +class TestReaders: # This is based on ExcelWriterBase @pytest.fixture(autouse=True, params=['xlrd', None]) @@ -837,7 +838,7 @@ def test_read_excel_squeeze(self, ext): tm.assert_series_equal(actual, expected) -@td.skip_if_no('xlrd', '1.0.0') +@td.skip_if_no('xlrd') @pytest.mark.parametrize("ext", ['.xls', '.xlsx', '.xlsm']) class TestRoundTrip: @@ -1038,9 +1039,9 @@ def test_read_excel_parse_dates(self, ext): tm.assert_frame_equal(df, res) -@td.skip_if_no('xlrd', '1.0.0') +@td.skip_if_no('xlrd') @pytest.mark.parametrize("ext", ['.xls', '.xlsx', '.xlsm']) -class TestXlrdReader(ReadingTestsBase): +class TestXlrdReader: """ This is the base class for the xlrd tests, and 3 different file formats are supported: xls, xlsx, xlsm From 417fc30f6d55f0424874383f2b0a1c515359bd6b Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Wed, 5 Jun 2019 10:17:57 -0400 Subject: [PATCH 3/5] Decoupled xlrd skips and base reading tests --- pandas/tests/io/test_excel.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/pandas/tests/io/test_excel.py b/pandas/tests/io/test_excel.py index 6a297969014f3..4efb5a7a5ec0e 100644 --- a/pandas/tests/io/test_excel.py +++ b/pandas/tests/io/test_excel.py @@ -51,12 +51,16 @@ def ignore_xlrd_time_clock_warning(): yield -@td.skip_if_no('xlrd') @pytest.mark.parametrize("ext", ['.xls', '.xlsx', '.xlsm']) class TestReaders: - # This is based on ExcelWriterBase - @pytest.fixture(autouse=True, params=['xlrd', None]) + @pytest.fixture(autouse=True, params=[ + # Add any engines to test here + pytest.param('xlrd', marks=pytest.mark.skipif( + not td.safe_import("xlrd"), reason="no xlrd")), + pytest.param(None, marks=pytest.mark.skipif( + not td.safe_import("xlrd"), reason="no xlrd")), + ]) def cd_and_set_engine(self, request, datapath, monkeypatch): """ Change directory and set engine for read_excel calls. @@ -74,7 +78,6 @@ def df_ref(self): parse_dates=True, engine='python') return df_ref - @td.skip_if_no("xlrd", "1.0.1") # see gh-22682 def test_usecols_int(self, ext, df_ref): df_ref = df_ref.reindex(columns=["A", "B", "C"]) @@ -96,7 +99,6 @@ def test_usecols_int(self, ext, df_ref): tm.assert_frame_equal(df1, df_ref, check_names=False) tm.assert_frame_equal(df2, df_ref, check_names=False) - @td.skip_if_no('xlrd', '1.0.1') # GH-22682 def test_usecols_list(self, ext, df_ref): df_ref = df_ref.reindex(columns=['B', 'C']) @@ -109,7 +111,6 @@ def test_usecols_list(self, ext, df_ref): tm.assert_frame_equal(df1, df_ref, check_names=False) tm.assert_frame_equal(df2, df_ref, check_names=False) - @td.skip_if_no('xlrd', '1.0.1') # GH-22682 def test_usecols_str(self, ext, df_ref): df1 = df_ref.reindex(columns=['A', 'B', 'C']) @@ -264,7 +265,6 @@ def test_excel_passes_na(self, ext): columns=['Test']) tm.assert_frame_equal(parsed, expected) - @td.skip_if_no('xlrd', '1.0.1') # GH-22682 @pytest.mark.parametrize('arg', ['sheet', 'sheetname', 'parse_cols']) def test_unexpected_kwargs_raises(self, ext, arg): # gh-17964 @@ -275,7 +275,6 @@ def test_unexpected_kwargs_raises(self, ext, arg): with pytest.raises(TypeError, match=msg): pd.read_excel(excel, **kwarg) - @td.skip_if_no('xlrd', '1.0.1') # GH-22682 def test_excel_table_sheet_by_index(self, ext, df_ref): excel = ExcelFile('test1' + ext) @@ -493,7 +492,6 @@ def test_date_conversion_overflow(self, ext): result = pd.read_excel('testdateoverflow' + ext) tm.assert_frame_equal(result, expected) - @td.skip_if_no("xlrd", "1.0.1") # see gh-22682 def test_sheet_name_and_sheetname(self, ext, df_ref): # gh-10559: Minor improvement: Change "sheet_name" to "sheetname" # gh-10969: DOC: Consistent var names (sheetname vs sheet_name) From a5d261670877ff0f623a598c0c5a458bec015095 Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Wed, 5 Jun 2019 12:06:06 -0400 Subject: [PATCH 4/5] Replaced *args with explicit fixture usage --- pandas/tests/io/test_excel.py | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/pandas/tests/io/test_excel.py b/pandas/tests/io/test_excel.py index 4efb5a7a5ec0e..6053bac350b80 100644 --- a/pandas/tests/io/test_excel.py +++ b/pandas/tests/io/test_excel.py @@ -1109,7 +1109,7 @@ class and any subclasses, on account of the `autouse=True` class TestExcelWriter(_WriterBase): # Base class for test cases to run with different Excel writers. - def test_excel_sheet_size(self): + def test_excel_sheet_size(self, merge_cells, engine, ext): # GH 26080 breaking_row_count = 2**20 + 1 @@ -1127,7 +1127,7 @@ def test_excel_sheet_size(self): with pytest.raises(ValueError, match=msg): col_df.to_excel(self.path) - def test_excel_sheet_by_name_raise(self, *_): + def test_excel_sheet_by_name_raise(self, merge_cells, engine, ext): import xlrd gt = DataFrame(np.random.randn(10, 2)) @@ -1141,7 +1141,8 @@ def test_excel_sheet_by_name_raise(self, *_): with pytest.raises(xlrd.XLRDError): pd.read_excel(xl, "0") - def test_excel_writer_context_manager(self, frame, *_): + def test_excel_writer_context_manager( + self, frame, merge_cells, engine, ext): with ExcelWriter(self.path) as writer: frame.to_excel(writer, "Data1") frame2 = frame.copy() @@ -1214,7 +1215,7 @@ def test_mixed(self, merge_cells, engine, ext, frame): recons = pd.read_excel(reader, 'test1', index_col=0) tm.assert_frame_equal(mixed_frame, recons) - def test_ts_frame(self, tsframe, *_): + def test_ts_frame(self, tsframe, merge_cells, engine, ext): df = tsframe df.to_excel(self.path, "test1") @@ -1280,7 +1281,7 @@ def test_bool_types(self, merge_cells, engine, ext, np_type): tm.assert_frame_equal(df, recons) - def test_inf_roundtrip(self, *_): + def test_inf_roundtrip(self, merge_cells, engine, ext): df = DataFrame([(1, np.inf), (2, 3), (5, -np.inf)]) df.to_excel(self.path, "test1") @@ -1396,7 +1397,7 @@ def test_excel_roundtrip_indexname(self, merge_cells, engine, ext): tm.assert_frame_equal(result, df) assert result.index.name == 'foo' - def test_excel_roundtrip_datetime(self, merge_cells, tsframe, *_): + def test_excel_roundtrip_datetime(self, merge_cells, tsframe, engine, ext): # datetime.date, not sure what to test here exactly tsf = tsframe.copy() @@ -1447,7 +1448,7 @@ def test_excel_date_datetime_format(self, merge_cells, engine, ext): # we need to use df_expected to check the result. tm.assert_frame_equal(rs2, df_expected) - def test_to_excel_interval_no_labels(self, *_): + def test_to_excel_interval_no_labels(self, merge_cells, engine, ext): # see gh-19242 # # Test writing Interval without labels. @@ -1464,7 +1465,7 @@ def test_to_excel_interval_no_labels(self, *_): recons = pd.read_excel(reader, "test1", index_col=0) tm.assert_frame_equal(expected, recons) - def test_to_excel_interval_labels(self, *_): + def test_to_excel_interval_labels(self, merge_cells, engine, ext): # see gh-19242 # # Test writing Interval with labels. @@ -1482,7 +1483,7 @@ def test_to_excel_interval_labels(self, *_): recons = pd.read_excel(reader, "test1", index_col=0) tm.assert_frame_equal(expected, recons) - def test_to_excel_timedelta(self, *_): + def test_to_excel_timedelta(self, merge_cells, engine, ext): # see gh-19242, gh-9155 # # Test writing timedelta to xls. @@ -1599,7 +1600,7 @@ def test_to_excel_multiindex_no_write_index(self, merge_cells, engine, # Test that it is the same as the initial frame. tm.assert_frame_equal(frame1, frame3) - def test_to_excel_float_format(self, *_): + def test_to_excel_float_format(self, merge_cells, engine, ext): df = DataFrame([[0.123456, 0.234567, 0.567567], [12.32112, 123123.2, 321321.2]], index=["A", "B"], columns=["X", "Y", "Z"]) @@ -1798,7 +1799,7 @@ def roundtrip(data, header=True, parser_hdr=0, index=True): for c in range(len(res.columns)): assert res.iloc[r, c] is not np.nan - def test_duplicated_columns(self, *_): + def test_duplicated_columns(self, merge_cells, engine, ext): # see gh-5235 df = DataFrame([[1, 2, 3], [1, 2, 3], [1, 2, 3]], columns=["A", "B", "B"]) @@ -1848,7 +1849,7 @@ def test_swapped_columns(self, merge_cells, engine, ext): tm.assert_series_equal(write_frame['A'], read_frame['A']) tm.assert_series_equal(write_frame['B'], read_frame['B']) - def test_invalid_columns(self, *_): + def test_invalid_columns(self, merge_cells, engine, ext): # see gh-10982 write_frame = DataFrame({"A": [1, 1, 1], "B": [2, 2, 2]}) @@ -1864,7 +1865,7 @@ def test_invalid_columns(self, *_): with pytest.raises(KeyError): write_frame.to_excel(self.path, "test1", columns=["C", "D"]) - def test_comment_arg(self, *_): + def test_comment_arg(self, merge_cells, engine, ext): # see gh-18735 # # Test the comment argument functionality to pd.read_excel. @@ -1898,7 +1899,7 @@ def test_comment_default(self, merge_cells, engine, ext): result2 = pd.read_excel(self.path, 'test_c', comment=None) tm.assert_frame_equal(result1, result2) - def test_comment_used(self, *_): + def test_comment_used(self, merge_cells, engine, ext): # see gh-18735 # # Test the comment argument is working as expected when used. @@ -1961,7 +1962,7 @@ def test_bytes_io(self, merge_cells, engine, ext): reread_df = pd.read_excel(bio, index_col=0) tm.assert_frame_equal(df, reread_df) - def test_write_lists_dict(self, *_): + def test_write_lists_dict(self, merge_cells, engine, ext): # see gh-8188. df = DataFrame({"mixed": ["a", ["b", "c"], {"d": "e", "f": 2}], "numeric": [1, 2, 3.0], @@ -1975,7 +1976,7 @@ def test_write_lists_dict(self, *_): tm.assert_frame_equal(read, expected) - def test_true_and_false_value_options(self, *_): + def test_true_and_false_value_options(self, merge_cells, engine, ext): # see gh-13347 df = pd.DataFrame([["foo", "bar"]], columns=["col1", "col2"]) expected = df.replace({"foo": True, "bar": False}) @@ -1985,7 +1986,7 @@ def test_true_and_false_value_options(self, *_): false_values=["bar"], index_col=0) tm.assert_frame_equal(read_frame, expected) - def test_freeze_panes(self, *_): + def test_freeze_panes(self, merge_cells, engine, ext): # see gh-15160 expected = DataFrame([[1, 2], [3, 4]], columns=["col1", "col2"]) expected.to_excel(self.path, "Sheet1", freeze_panes=(1, 1)) From 7fc3f7627e1bae75a703a5885e3e9ec589e0de6b Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Wed, 5 Jun 2019 12:11:15 -0400 Subject: [PATCH 5/5] Removed unnecessary merge_cells parametrization --- pandas/tests/io/test_excel.py | 90 +++++++++++++++++------------------ 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/pandas/tests/io/test_excel.py b/pandas/tests/io/test_excel.py index 6053bac350b80..6860afa710c4a 100644 --- a/pandas/tests/io/test_excel.py +++ b/pandas/tests/io/test_excel.py @@ -37,6 +37,11 @@ def tsframe(): return tm.makeTimeDataFrame()[:5] +@pytest.fixture(params=[True, False]) +def merge_cells(request): + return request.param + + @contextlib.contextmanager def ignore_xlrd_time_clock_warning(): """ @@ -1069,7 +1074,7 @@ def test_read_xlrd_book(self, ext, frame): class _WriterBase: @pytest.fixture(autouse=True) - def set_engine_and_path(self, request, merge_cells, engine, ext): + def set_engine_and_path(self, request, engine, ext): """Fixture to set engine and open file for use in each test case Rather than requiring `engine=...` to be provided explicitly as an @@ -1095,7 +1100,6 @@ class and any subclasses, on account of the `autouse=True` set_option(option_name, prev_engine) # Roll back option change -@pytest.mark.parametrize("merge_cells", [True, False]) @pytest.mark.parametrize("engine,ext", [ pytest.param('openpyxl', '.xlsx', marks=pytest.mark.skipif( not td.safe_import('openpyxl'), reason='No openpyxl')), @@ -1109,7 +1113,7 @@ class and any subclasses, on account of the `autouse=True` class TestExcelWriter(_WriterBase): # Base class for test cases to run with different Excel writers. - def test_excel_sheet_size(self, merge_cells, engine, ext): + def test_excel_sheet_size(self, engine, ext): # GH 26080 breaking_row_count = 2**20 + 1 @@ -1127,7 +1131,7 @@ def test_excel_sheet_size(self, merge_cells, engine, ext): with pytest.raises(ValueError, match=msg): col_df.to_excel(self.path) - def test_excel_sheet_by_name_raise(self, merge_cells, engine, ext): + def test_excel_sheet_by_name_raise(self, engine, ext): import xlrd gt = DataFrame(np.random.randn(10, 2)) @@ -1141,8 +1145,7 @@ def test_excel_sheet_by_name_raise(self, merge_cells, engine, ext): with pytest.raises(xlrd.XLRDError): pd.read_excel(xl, "0") - def test_excel_writer_context_manager( - self, frame, merge_cells, engine, ext): + def test_excel_writer_context_manager(self, frame, engine, ext): with ExcelWriter(self.path) as writer: frame.to_excel(writer, "Data1") frame2 = frame.copy() @@ -1156,7 +1159,7 @@ def test_excel_writer_context_manager( tm.assert_frame_equal(found_df, frame) tm.assert_frame_equal(found_df2, frame2) - def test_roundtrip(self, merge_cells, engine, ext, frame): + def test_roundtrip(self, engine, ext, frame): frame = frame.copy() frame['A'][:5] = nan @@ -1206,7 +1209,7 @@ def test_roundtrip(self, merge_cells, engine, ext, frame): recons = pd.read_excel(self.path, index_col=0) tm.assert_frame_equal(s.to_frame(), recons) - def test_mixed(self, merge_cells, engine, ext, frame): + def test_mixed(self, engine, ext, frame): mixed_frame = frame.copy() mixed_frame['foo'] = 'bar' @@ -1215,7 +1218,7 @@ def test_mixed(self, merge_cells, engine, ext, frame): recons = pd.read_excel(reader, 'test1', index_col=0) tm.assert_frame_equal(mixed_frame, recons) - def test_ts_frame(self, tsframe, merge_cells, engine, ext): + def test_ts_frame(self, tsframe, engine, ext): df = tsframe df.to_excel(self.path, "test1") @@ -1224,7 +1227,7 @@ def test_ts_frame(self, tsframe, merge_cells, engine, ext): recons = pd.read_excel(reader, "test1", index_col=0) tm.assert_frame_equal(df, recons) - def test_basics_with_nan(self, merge_cells, engine, ext, frame): + def test_basics_with_nan(self, engine, ext, frame): frame = frame.copy() frame['A'][:5] = nan frame.to_excel(self.path, 'test1') @@ -1234,7 +1237,7 @@ def test_basics_with_nan(self, merge_cells, engine, ext, frame): @pytest.mark.parametrize("np_type", [ np.int8, np.int16, np.int32, np.int64]) - def test_int_types(self, merge_cells, engine, ext, np_type): + def test_int_types(self, engine, ext, np_type): # Test np.int values read come back as int # (rather than float which is Excel's format). df = DataFrame(np.random.randint(-10, 10, size=(10, 2)), @@ -1260,7 +1263,7 @@ def test_int_types(self, merge_cells, engine, ext, np_type): @pytest.mark.parametrize("np_type", [ np.float16, np.float32, np.float64]) - def test_float_types(self, merge_cells, engine, ext, np_type): + def test_float_types(self, engine, ext, np_type): # Test np.float values read come back as float. df = DataFrame(np.random.random_sample(10), dtype=np_type) df.to_excel(self.path, "test1") @@ -1271,7 +1274,7 @@ def test_float_types(self, merge_cells, engine, ext, np_type): tm.assert_frame_equal(df, recons, check_dtype=False) @pytest.mark.parametrize("np_type", [np.bool8, np.bool_]) - def test_bool_types(self, merge_cells, engine, ext, np_type): + def test_bool_types(self, engine, ext, np_type): # Test np.bool values read come back as float. df = (DataFrame([1, 0, True, False], dtype=np_type)) df.to_excel(self.path, "test1") @@ -1281,7 +1284,7 @@ def test_bool_types(self, merge_cells, engine, ext, np_type): tm.assert_frame_equal(df, recons) - def test_inf_roundtrip(self, merge_cells, engine, ext): + def test_inf_roundtrip(self, engine, ext): df = DataFrame([(1, np.inf), (2, 3), (5, -np.inf)]) df.to_excel(self.path, "test1") @@ -1290,7 +1293,7 @@ def test_inf_roundtrip(self, merge_cells, engine, ext): tm.assert_frame_equal(df, recons) - def test_sheets(self, merge_cells, engine, ext, frame, tsframe): + def test_sheets(self, engine, ext, frame, tsframe): frame = frame.copy() frame['A'][:5] = nan @@ -1313,7 +1316,7 @@ def test_sheets(self, merge_cells, engine, ext, frame, tsframe): assert 'test1' == reader.sheet_names[0] assert 'test2' == reader.sheet_names[1] - def test_colaliases(self, merge_cells, engine, ext, frame): + def test_colaliases(self, engine, ext, frame): frame = frame.copy() frame['A'][:5] = nan @@ -1409,7 +1412,7 @@ def test_excel_roundtrip_datetime(self, merge_cells, tsframe, engine, ext): tm.assert_frame_equal(tsframe, recons) - def test_excel_date_datetime_format(self, merge_cells, engine, ext): + def test_excel_date_datetime_format(self, engine, ext): # see gh-4133 # # Excel output format strings @@ -1448,7 +1451,7 @@ def test_excel_date_datetime_format(self, merge_cells, engine, ext): # we need to use df_expected to check the result. tm.assert_frame_equal(rs2, df_expected) - def test_to_excel_interval_no_labels(self, merge_cells, engine, ext): + def test_to_excel_interval_no_labels(self, engine, ext): # see gh-19242 # # Test writing Interval without labels. @@ -1465,7 +1468,7 @@ def test_to_excel_interval_no_labels(self, merge_cells, engine, ext): recons = pd.read_excel(reader, "test1", index_col=0) tm.assert_frame_equal(expected, recons) - def test_to_excel_interval_labels(self, merge_cells, engine, ext): + def test_to_excel_interval_labels(self, engine, ext): # see gh-19242 # # Test writing Interval with labels. @@ -1483,7 +1486,7 @@ def test_to_excel_interval_labels(self, merge_cells, engine, ext): recons = pd.read_excel(reader, "test1", index_col=0) tm.assert_frame_equal(expected, recons) - def test_to_excel_timedelta(self, merge_cells, engine, ext): + def test_to_excel_timedelta(self, engine, ext): # see gh-19242, gh-9155 # # Test writing timedelta to xls. @@ -1501,8 +1504,7 @@ def test_to_excel_timedelta(self, merge_cells, engine, ext): recons = pd.read_excel(reader, "test1", index_col=0) tm.assert_frame_equal(expected, recons) - def test_to_excel_periodindex( - self, merge_cells, engine, ext, tsframe): + def test_to_excel_periodindex(self, engine, ext, tsframe): xp = tsframe.resample('M', kind='period').mean() xp.to_excel(self.path, 'sht1') @@ -1527,8 +1529,7 @@ def test_to_excel_multiindex(self, merge_cells, engine, ext, frame): tm.assert_frame_equal(frame, df) # GH13511 - def test_to_excel_multiindex_nan_label( - self, merge_cells, engine, ext): + def test_to_excel_multiindex_nan_label(self, merge_cells, engine, ext): df = pd.DataFrame({'A': [None, 2, 3], 'B': [10, 20, 30], 'C': np.random.sample(3)}) @@ -1578,8 +1579,7 @@ def test_to_excel_multiindex_dates( tm.assert_frame_equal(tsframe, recons) assert recons.index.names == ('time', 'foo') - def test_to_excel_multiindex_no_write_index(self, merge_cells, engine, - ext): + def test_to_excel_multiindex_no_write_index(self, engine, ext): # Test writing and re-reading a MI witout the index. GH 5616. # Initial non-MI frame. @@ -1600,7 +1600,7 @@ def test_to_excel_multiindex_no_write_index(self, merge_cells, engine, # Test that it is the same as the initial frame. tm.assert_frame_equal(frame1, frame3) - def test_to_excel_float_format(self, merge_cells, engine, ext): + def test_to_excel_float_format(self, engine, ext): df = DataFrame([[0.123456, 0.234567, 0.567567], [12.32112, 123123.2, 321321.2]], index=["A", "B"], columns=["X", "Y", "Z"]) @@ -1614,7 +1614,7 @@ def test_to_excel_float_format(self, merge_cells, engine, ext): index=["A", "B"], columns=["X", "Y", "Z"]) tm.assert_frame_equal(result, expected) - def test_to_excel_output_encoding(self, merge_cells, engine, ext): + def test_to_excel_output_encoding(self, engine, ext): # Avoid mixed inferred_type. df = DataFrame([["\u0192", "\u0193", "\u0194"], ["\u0195", "\u0196", "\u0197"]], @@ -1627,7 +1627,7 @@ def test_to_excel_output_encoding(self, merge_cells, engine, ext): encoding="utf8", index_col=0) tm.assert_frame_equal(result, df) - def test_to_excel_unicode_filename(self, merge_cells, engine, ext): + def test_to_excel_unicode_filename(self, engine, ext): with ensure_clean("\u0192u." + ext) as filename: try: f = open(filename, "wb") @@ -1649,7 +1649,7 @@ def test_to_excel_unicode_filename(self, merge_cells, engine, ext): index=["A", "B"], columns=["X", "Y", "Z"]) tm.assert_frame_equal(result, expected) - # def test_to_excel_header_styling_xls(self, merge_cells, engine, ext): + # def test_to_excel_header_styling_xls(self, engine, ext): # import StringIO # s = StringIO( @@ -1696,7 +1696,7 @@ def test_to_excel_unicode_filename(self, merge_cells, engine, ext): # assert 1 == cell_xf.border.left_line_style # assert 2 == cell_xf.alignment.hor_align # os.remove(filename) - # def test_to_excel_header_styling_xlsx(self, merge_cells, engine, ext): + # def test_to_excel_header_styling_xlsx(self, engine, ext): # import StringIO # s = StringIO( # """Date,ticker,type,value @@ -1799,7 +1799,7 @@ def roundtrip(data, header=True, parser_hdr=0, index=True): for c in range(len(res.columns)): assert res.iloc[r, c] is not np.nan - def test_duplicated_columns(self, merge_cells, engine, ext): + def test_duplicated_columns(self, engine, ext): # see gh-5235 df = DataFrame([[1, 2, 3], [1, 2, 3], [1, 2, 3]], columns=["A", "B", "B"]) @@ -1838,7 +1838,7 @@ def test_duplicated_columns(self, merge_cells, engine, ext): pd.read_excel( self.path, "test1", header=None, mangle_dupe_cols=False) - def test_swapped_columns(self, merge_cells, engine, ext): + def test_swapped_columns(self, engine, ext): # Test for issue #5427. write_frame = DataFrame({'A': [1, 1, 1], 'B': [2, 2, 2]}) @@ -1849,7 +1849,7 @@ def test_swapped_columns(self, merge_cells, engine, ext): tm.assert_series_equal(write_frame['A'], read_frame['A']) tm.assert_series_equal(write_frame['B'], read_frame['B']) - def test_invalid_columns(self, merge_cells, engine, ext): + def test_invalid_columns(self, engine, ext): # see gh-10982 write_frame = DataFrame({"A": [1, 1, 1], "B": [2, 2, 2]}) @@ -1865,7 +1865,7 @@ def test_invalid_columns(self, merge_cells, engine, ext): with pytest.raises(KeyError): write_frame.to_excel(self.path, "test1", columns=["C", "D"]) - def test_comment_arg(self, merge_cells, engine, ext): + def test_comment_arg(self, engine, ext): # see gh-18735 # # Test the comment argument functionality to pd.read_excel. @@ -1885,7 +1885,7 @@ def test_comment_arg(self, merge_cells, engine, ext): result2 = pd.read_excel(self.path, "test_c", comment="#", index_col=0) tm.assert_frame_equal(result1, result2) - def test_comment_default(self, merge_cells, engine, ext): + def test_comment_default(self, engine, ext): # Re issue #18735 # Test the comment argument default to pd.read_excel @@ -1899,7 +1899,7 @@ def test_comment_default(self, merge_cells, engine, ext): result2 = pd.read_excel(self.path, 'test_c', comment=None) tm.assert_frame_equal(result1, result2) - def test_comment_used(self, merge_cells, engine, ext): + def test_comment_used(self, engine, ext): # see gh-18735 # # Test the comment argument is working as expected when used. @@ -1915,7 +1915,7 @@ def test_comment_used(self, merge_cells, engine, ext): result = pd.read_excel(self.path, "test_c", comment="#", index_col=0) tm.assert_frame_equal(result, expected) - def test_comment_empty_line(self, merge_cells, engine, ext): + def test_comment_empty_line(self, engine, ext): # Re issue #18735 # Test that pd.read_excel ignores commented lines at the end of file @@ -1927,7 +1927,7 @@ def test_comment_empty_line(self, merge_cells, engine, ext): result = pd.read_excel(self.path, comment='#') tm.assert_frame_equal(result, expected) - def test_datetimes(self, merge_cells, engine, ext): + def test_datetimes(self, engine, ext): # Test writing and reading datetimes. For issue #9139. (xref #9185) datetimes = [datetime(2013, 1, 13, 1, 2, 3), @@ -1948,7 +1948,7 @@ def test_datetimes(self, merge_cells, engine, ext): tm.assert_series_equal(write_frame['A'], read_frame['A']) - def test_bytes_io(self, merge_cells, engine, ext): + def test_bytes_io(self, engine, ext): # see gh-7074 bio = BytesIO() df = DataFrame(np.random.randn(10, 2)) @@ -1962,7 +1962,7 @@ def test_bytes_io(self, merge_cells, engine, ext): reread_df = pd.read_excel(bio, index_col=0) tm.assert_frame_equal(df, reread_df) - def test_write_lists_dict(self, merge_cells, engine, ext): + def test_write_lists_dict(self, engine, ext): # see gh-8188. df = DataFrame({"mixed": ["a", ["b", "c"], {"d": "e", "f": 2}], "numeric": [1, 2, 3.0], @@ -1976,7 +1976,7 @@ def test_write_lists_dict(self, merge_cells, engine, ext): tm.assert_frame_equal(read, expected) - def test_true_and_false_value_options(self, merge_cells, engine, ext): + def test_true_and_false_value_options(self, engine, ext): # see gh-13347 df = pd.DataFrame([["foo", "bar"]], columns=["col1", "col2"]) expected = df.replace({"foo": True, "bar": False}) @@ -1986,7 +1986,7 @@ def test_true_and_false_value_options(self, merge_cells, engine, ext): false_values=["bar"], index_col=0) tm.assert_frame_equal(read_frame, expected) - def test_freeze_panes(self, merge_cells, engine, ext): + def test_freeze_panes(self, engine, ext): # see gh-15160 expected = DataFrame([[1, 2], [3, 4]], columns=["col1", "col2"]) expected.to_excel(self.path, "Sheet1", freeze_panes=(1, 1)) @@ -1994,7 +1994,7 @@ def test_freeze_panes(self, merge_cells, engine, ext): result = pd.read_excel(self.path, index_col=0) tm.assert_frame_equal(result, expected) - def test_path_path_lib(self, merge_cells, engine, ext): + def test_path_path_lib(self, engine, ext): df = tm.makeDataFrame() writer = partial(df.to_excel, engine=engine) @@ -2003,7 +2003,7 @@ def test_path_path_lib(self, merge_cells, engine, ext): path="foo.{ext}".format(ext=ext)) tm.assert_frame_equal(result, df) - def test_path_local_path(self, merge_cells, engine, ext): + def test_path_local_path(self, engine, ext): df = tm.makeDataFrame() writer = partial(df.to_excel, engine=engine)