Skip to content

Commit 6b39800

Browse files
committed
TST: Add xlsm to Excel parsing tests.
Added an Excel xlsm file to the excel.py reader tests. Test for issue #4172
1 parent da59b11 commit 6b39800

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

pandas/io/tests/data/test.xlsm

44 KB
Binary file not shown.

pandas/io/tests/test_excel.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ def test_parse_cols_int(self):
9090
_skip_if_no_openpyxl()
9191
_skip_if_no_xlrd()
9292

93-
suffix = ['', 'x']
93+
suffix = ['xls', 'xlsx', 'xlsm']
9494

9595
for s in suffix:
96-
pth = os.path.join(self.dirpath, 'test.xls%s' % s)
96+
pth = os.path.join(self.dirpath, 'test.%s' % s)
9797
xls = ExcelFile(pth)
9898
df = xls.parse('Sheet1', index_col=0, parse_dates=True,
9999
parse_cols=3)
@@ -109,10 +109,10 @@ def test_parse_cols_list(self):
109109
_skip_if_no_openpyxl()
110110
_skip_if_no_xlrd()
111111

112-
suffix = ['', 'x']
112+
suffix = ['xls', 'xlsx', 'xlsm']
113113

114114
for s in suffix:
115-
pth = os.path.join(self.dirpath, 'test.xls%s' % s)
115+
pth = os.path.join(self.dirpath, 'test.%s' % s)
116116
xls = ExcelFile(pth)
117117
df = xls.parse('Sheet1', index_col=0, parse_dates=True,
118118
parse_cols=[0, 2, 3])
@@ -129,11 +129,11 @@ def test_parse_cols_str(self):
129129
_skip_if_no_openpyxl()
130130
_skip_if_no_xlrd()
131131

132-
suffix = ['', 'x']
132+
suffix = ['xls', 'xlsx', 'xlsm']
133133

134134
for s in suffix:
135135

136-
pth = os.path.join(self.dirpath, 'test.xls%s' % s)
136+
pth = os.path.join(self.dirpath, 'test.%s' % s)
137137
xls = ExcelFile(pth)
138138

139139
df = xls.parse('Sheet1', index_col=0, parse_dates=True,
@@ -677,26 +677,26 @@ def test_excel_date_datetime_format(self):
677677
with ensure_clean(self.ext) as filename1:
678678
with ensure_clean(self.ext) as filename2:
679679
writer1 = ExcelWriter(filename1)
680-
writer2 = ExcelWriter(filename2,
680+
writer2 = ExcelWriter(filename2,
681681
date_format='DD.MM.YYYY',
682682
datetime_format='DD.MM.YYYY HH-MM-SS')
683683

684684
df.to_excel(writer1, 'test1')
685685
df.to_excel(writer2, 'test1')
686-
686+
687687
writer1.close()
688688
writer2.close()
689689

690690
reader1 = ExcelFile(filename1)
691691
reader2 = ExcelFile(filename2)
692-
692+
693693
rs1 = reader1.parse('test1', index_col=None)
694694
rs2 = reader2.parse('test1', index_col=None)
695-
695+
696696
tm.assert_frame_equal(rs1, rs2)
697697

698698
# since the reader returns a datetime object for dates, we need
699-
# to use df_expected to check the result
699+
# to use df_expected to check the result
700700
tm.assert_frame_equal(rs2, df_expected)
701701

702702
def test_to_excel_periodindex(self):

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,7 @@ def pxd(name):
567567
'tests/data/*.txt',
568568
'tests/data/*.xls',
569569
'tests/data/*.xlsx',
570+
'tests/data/*.xlsm',
570571
'tests/data/*.table',
571572
'tests/data/*.html',
572573
'tests/test_json/data/*.json'],

0 commit comments

Comments
 (0)