Skip to content

Commit 0f9d7f6

Browse files
committed
Split test_excel.py (pandas-dev#24472)
1 parent f6309d9 commit 0f9d7f6

File tree

4 files changed

+15
-2585
lines changed

4 files changed

+15
-2585
lines changed

pandas/tests/io/excel/base.py

+5-9
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ def set_engine(self, request):
8282
[1, 0, 3], [1, 3, 0],
8383
[3, 0, 1], [3, 1, 0],
8484
])
85-
8685
def test_usecols_diff_positional_int_columns_order(self, ext, usecols):
8786
expected = self.get_csv_refdf("test1")[["A", "C"]]
8887
result = self.get_exceldf("test1", ext, "Sheet1",
@@ -92,7 +91,6 @@ def test_usecols_diff_positional_int_columns_order(self, ext, usecols):
9291
@pytest.mark.parametrize("usecols", [
9392
["B", "D"], ["D", "B"]
9493
])
95-
9694
def test_usecols_diff_positional_str_columns_order(self, ext, usecols):
9795
expected = self.get_csv_refdf("test1")[["B", "D"]]
9896
expected.index = range(len(expected))
@@ -931,7 +929,7 @@ def test_read_excel_squeeze(self, ext):
931929
actual = pd.read_excel(f, 'one_column', squeeze=True)
932930
expected = pd.Series([1, 2, 3], name='a')
933931
tm.assert_series_equal(actual, expected)
934-
932+
935933

936934
class _WriterBase(SharedItems):
937935

@@ -973,8 +971,6 @@ class and any subclasses, on account of the `autouse=True`
973971
pytest.param('xlsxwriter', '.xlsx', marks=pytest.mark.skipif(
974972
not td.safe_import('xlsxwriter'), reason='No xlsxwriter'))
975973
])
976-
977-
978974
class TestExcelWriter(_WriterBase):
979975
# Base class for test cases to run with different Excel writers.
980976

@@ -1958,7 +1954,7 @@ def test_write_append_mode(self, merge_cells, ext, engine, mode, expected):
19581954

19591955
for index, cell_value in enumerate(expected):
19601956
assert wb2.worksheets[index]['A1'].value == cell_value
1961-
1957+
19621958

19631959
@td.skip_if_no('xlwt')
19641960
@pytest.mark.parametrize("merge_cells,ext,engine", [
@@ -2019,7 +2015,7 @@ def test_write_append_mode_raises(self, merge_cells, ext, engine):
20192015
with ensure_clean(ext) as f:
20202016
with pytest.raises(ValueError, match=msg):
20212017
ExcelWriter(f, engine=engine, mode='a')
2022-
2018+
20232019

20242020
@td.skip_if_no('xlsxwriter')
20252021
@pytest.mark.parametrize("merge_cells,ext,engine", [
@@ -2142,7 +2138,7 @@ def check_called(func):
21422138
check_called(
21432139
lambda: df.to_excel(
21442140
'something.xls', engine='dummy'))
2145-
2141+
21462142

21472143
@pytest.mark.parametrize('engine', [
21482144
pytest.param('xlwt',
@@ -2294,7 +2290,7 @@ def custom_converter(css):
22942290
n_cells += 1
22952291

22962292
assert n_cells == (11 + 1) * (3 + 1)
2297-
2293+
22982294

22992295
@td.skip_if_no('openpyxl')
23002296
@pytest.mark.skipif(not PY36, reason='requires fspath')

pandas/tests/io/excel/xlrd.py

+9-12
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ def get_exceldf(self, basename, ext, *args, **kwds):
8383
"""
8484
pth = os.path.join(self.dirpath, basename + ext)
8585
return read_excel(pth, *args, **kwds)
86-
87-
86+
87+
8888
class XlrdReadingTestsBase(XlrdSharedItems):
8989
# This is based on ExcelWriterBase
90-
90+
9191
@pytest.fixture(autouse=True, params=['xlrd'])
9292
def set_engine(self, request):
9393
func_name = "get_exceldf"
@@ -102,7 +102,6 @@ def set_engine(self, request):
102102
[1, 0, 3], [1, 3, 0],
103103
[3, 0, 1], [3, 1, 0],
104104
])
105-
106105
@td.skip_if_no("xlrd", "1.0.1") # see gh-22682
107106
def test_usecols_int(self, ext):
108107

@@ -192,7 +191,7 @@ def test_usecols_str(self, ext):
192191
index_col=0, usecols='A,C:D')
193192
tm.assert_frame_equal(df2, df1, check_names=False)
194193
tm.assert_frame_equal(df3, df1, check_names=False)
195-
194+
196195
@td.skip_if_no('xlrd', '1.0.1') # GH-22682
197196
def test_deprecated_sheetname(self, ext):
198197
# gh-17964
@@ -233,7 +232,7 @@ def test_excel_table_sheet_by_index(self, ext):
233232
import xlrd
234233
with pytest.raises(xlrd.XLRDError):
235234
read_excel(excel, 'asdf')
236-
235+
237236
@td.skip_if_no("xlrd", "1.0.1") # see gh-22682
238237
def test_sheet_name_and_sheetname(self, ext):
239238
# gh-10559: Minor improvement: Change "sheet_name" to "sheetname"
@@ -262,7 +261,7 @@ def test_sheet_name_and_sheetname(self, ext):
262261
tm.assert_frame_equal(df2, df_ref, check_names=False)
263262
tm.assert_frame_equal(df1_parse, df_ref, check_names=False)
264263
tm.assert_frame_equal(df2_parse, df_ref, check_names=False)
265-
264+
266265

267266
@pytest.mark.parametrize("ext", ['.xls', '.xlsx', '.xlsm'])
268267
class TestXlrdReader(XlrdReadingTestsBase):
@@ -290,8 +289,8 @@ def test_read_xlrd_book(self, ext):
290289
result = read_excel(book, sheet_name=sheet_name,
291290
engine=engine, index_col=0)
292291
tm.assert_frame_equal(df, result)
293-
294-
292+
293+
295294
class _XlrdWriterBase(XlrdSharedItems):
296295

297296
@pytest.fixture(autouse=True)
@@ -332,8 +331,6 @@ class and any subclasses, on account of the `autouse=True`
332331
pytest.param('xlsxwriter', '.xlsx', marks=pytest.mark.skipif(
333332
not td.safe_import('xlsxwriter'), reason='No xlsxwriter'))
334333
])
335-
336-
337334
class XlrdTestExcelWriter(_XlrdWriterBase):
338335
# Base class for test cases to run with different Excel writers.
339336

@@ -349,4 +346,4 @@ def test_excel_sheet_by_name_raise(self, *_):
349346
tm.assert_frame_equal(gt, df)
350347

351348
with pytest.raises(xlrd.XLRDError):
352-
read_excel(xl, "0")
349+
read_excel(xl, "0")

pandas/tests/io/formats/test_to_excel.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Tests formatting as writer-agnostic ExcelCells
22
3-
ExcelFormatter is tested implicitly in pandas/tests/io/test_excel.py
3+
ExcelFormatter is tested implicitly in pandas/tests/io/mainF.py
44
"""
55

66
import pytest

0 commit comments

Comments
 (0)