Skip to content

Commit

Permalink
Removed unnecessary merge_cells parametrization
Browse files Browse the repository at this point in the history
  • Loading branch information
WillAyd committed Jun 5, 2019
1 parent a5d2616 commit 7fc3f76
Showing 1 changed file with 45 additions and 45 deletions.
90 changes: 45 additions & 45 deletions pandas/tests/io/test_excel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
"""
Expand Down Expand Up @@ -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
Expand All @@ -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')),
Expand All @@ -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
Expand All @@ -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))
Expand All @@ -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()
Expand All @@ -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

Expand Down Expand Up @@ -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'

Expand All @@ -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")
Expand All @@ -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')
Expand All @@ -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)),
Expand All @@ -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")
Expand All @@ -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")
Expand All @@ -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")

Expand All @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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')
Expand All @@ -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)})
Expand Down Expand Up @@ -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.
Expand All @@ -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"])
Expand All @@ -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"]],
Expand All @@ -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")
Expand All @@ -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(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"])
Expand Down Expand Up @@ -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]})
Expand All @@ -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]})
Expand All @@ -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.
Expand All @@ -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

Expand All @@ -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.
Expand All @@ -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

Expand All @@ -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),
Expand All @@ -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))
Expand All @@ -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],
Expand All @@ -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})
Expand All @@ -1986,15 +1986,15 @@ 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))

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)

Expand All @@ -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)

Expand Down

0 comments on commit 7fc3f76

Please sign in to comment.