Skip to content

Commit e12397c

Browse files
committed
incorporate new test structure
1 parent 7a18637 commit e12397c

File tree

5 files changed

+39
-40
lines changed

5 files changed

+39
-40
lines changed

pandas/io/excel.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,8 @@ def parse(self, sheetname=0, header=0, skiprows=None, skip_footer=0,
281281
warn("\nThe has_index_names argument is deprecated; index names "
282282
"will be automatically inferred based on index_col.\n"
283283
"This argmument is still necessary if reading Excel output "
284-
"from 0.16.2 or prior with index names.", FutureWarning)
284+
"from 0.16.2 or prior with index names.", FutureWarning,
285+
stacklevel=3)
285286

286287
return self._parse_excel(sheetname=sheetname, header=header,
287288
skiprows=skiprows,
Binary file not shown.
10.6 KB
Binary file not shown.
14 KB
Binary file not shown.

pandas/io/tests/test_excel.py

Lines changed: 37 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import numpy as np
1515
from numpy.testing.decorators import slow
1616

17+
import pandas as pd
1718
from pandas import DataFrame, Index, MultiIndex
1819
from pandas.io.parsers import read_csv
1920
from pandas.io.excel import (
@@ -416,7 +417,7 @@ def test_read_xlrd_Book(self):
416417
@tm.network
417418
def test_read_from_http_url(self):
418419
url = ('https://raw.github.com/pydata/pandas/master/'
419-
'pandas/io/tests/data/test' + self.ext)
420+
'pandas/io/tests/data/test1' + self.ext)
420421
url_table = read_excel(url)
421422
local_table = self.get_exceldf('test1')
422423
tm.assert_frame_equal(url_table, local_table)
@@ -517,56 +518,54 @@ def test_reader_seconds(self):
517518

518519
def test_read_excel_multiindex(self):
519520
#GH 4679
520-
_skip_if_no_xlrd()
521521
mi = MultiIndex.from_product([['foo','bar'],['a','b']])
522-
for ext in ['.xls', '.xlsx']:
523-
mi_file = os.path.join(self.dirpath, 'testmultiindex' + ext)
522+
mi_file = os.path.join(self.dirpath, 'testmultiindex' + self.ext)
524523

525-
expected = DataFrame([[1, 2.5, pd.Timestamp('2015-01-01'), True],
526-
[2, 3.5, pd.Timestamp('2015-01-02'), False],
527-
[3, 4.5, pd.Timestamp('2015-01-03'), False],
528-
[4, 5.5, pd.Timestamp('2015-01-04'), True]],
529-
columns = mi)
524+
expected = DataFrame([[1, 2.5, pd.Timestamp('2015-01-01'), True],
525+
[2, 3.5, pd.Timestamp('2015-01-02'), False],
526+
[3, 4.5, pd.Timestamp('2015-01-03'), False],
527+
[4, 5.5, pd.Timestamp('2015-01-04'), True]],
528+
columns = mi)
530529

531-
actual = read_excel(mi_file, 'mi_column', header=[0,1])
532-
tm.assert_frame_equal(actual, expected)
533-
actual = read_excel(mi_file, 'mi_column', header=[0,1], index_col=0)
534-
tm.assert_frame_equal(actual, expected)
530+
actual = read_excel(mi_file, 'mi_column', header=[0,1])
531+
tm.assert_frame_equal(actual, expected)
532+
actual = read_excel(mi_file, 'mi_column', header=[0,1], index_col=0)
533+
tm.assert_frame_equal(actual, expected)
535534

536-
expected.columns = ['a', 'b', 'c', 'd']
537-
expected.index = mi
538-
actual = read_excel(mi_file, 'mi_index', index_col=[0,1])
539-
tm.assert_frame_equal(actual, expected, check_names=False)
535+
expected.columns = ['a', 'b', 'c', 'd']
536+
expected.index = mi
537+
actual = read_excel(mi_file, 'mi_index', index_col=[0,1])
538+
tm.assert_frame_equal(actual, expected, check_names=False)
540539

541-
expected.columns = mi
542-
actual = read_excel(mi_file, 'both', index_col=[0,1], header=[0,1])
543-
tm.assert_frame_equal(actual, expected, check_names=False)
540+
expected.columns = mi
541+
actual = read_excel(mi_file, 'both', index_col=[0,1], header=[0,1])
542+
tm.assert_frame_equal(actual, expected, check_names=False)
544543

545-
expected.index = mi.set_names(['ilvl1', 'ilvl2'])
546-
expected.columns = ['a', 'b', 'c', 'd']
547-
actual = read_excel(mi_file, 'mi_index_name', index_col=[0,1])
548-
tm.assert_frame_equal(actual, expected)
544+
expected.index = mi.set_names(['ilvl1', 'ilvl2'])
545+
expected.columns = ['a', 'b', 'c', 'd']
546+
actual = read_excel(mi_file, 'mi_index_name', index_col=[0,1])
547+
tm.assert_frame_equal(actual, expected)
549548

550-
expected.index = list(range(4))
551-
expected.columns = mi.set_names(['c1', 'c2'])
552-
actual = read_excel(mi_file, 'mi_column_name', header=[0,1], index_col=0)
553-
tm.assert_frame_equal(actual, expected)
549+
expected.index = list(range(4))
550+
expected.columns = mi.set_names(['c1', 'c2'])
551+
actual = read_excel(mi_file, 'mi_column_name', header=[0,1], index_col=0)
552+
tm.assert_frame_equal(actual, expected)
554553

555-
expected.index = mi.set_names(['ilvl1', 'ilvl2'])
556-
actual = read_excel(mi_file, 'both_name', index_col=[0,1], header=[0,1])
557-
tm.assert_frame_equal(actual, expected)
554+
expected.index = mi.set_names(['ilvl1', 'ilvl2'])
555+
actual = read_excel(mi_file, 'both_name', index_col=[0,1], header=[0,1])
556+
tm.assert_frame_equal(actual, expected)
558557

559-
actual = read_excel(mi_file, 'both_name', index_col=[0,1], header=[0,1])
560-
tm.assert_frame_equal(actual, expected)
558+
actual = read_excel(mi_file, 'both_name', index_col=[0,1], header=[0,1])
559+
tm.assert_frame_equal(actual, expected)
561560

562-
actual = read_excel(mi_file, 'both_name_skiprows', index_col=[0,1],
563-
header=[0,1], skiprows=2)
564-
tm.assert_frame_equal(actual, expected)
561+
actual = read_excel(mi_file, 'both_name_skiprows', index_col=[0,1],
562+
header=[0,1], skiprows=2)
563+
tm.assert_frame_equal(actual, expected)
565564

566565

567566
def test_excel_multindex_roundtrip(self):
568567
#GH 4679
569-
_skip_if_no_xlrd()
568+
_skip_if_no_xlsxwriter()
570569
with ensure_clean('.xlsx') as pth:
571570
for c_idx_names in [True, False]:
572571
for r_idx_names in [True, False]:
@@ -603,7 +602,6 @@ def test_excel_multindex_roundtrip(self):
603602

604603
def test_excel_oldindex_format(self):
605604
#GH 4679
606-
_skip_if_no_xlrd()
607605
data = np.array([['R0C0', 'R0C1', 'R0C2', 'R0C3', 'R0C4'],
608606
['R1C0', 'R1C1', 'R1C2', 'R1C3', 'R1C4'],
609607
['R2C0', 'R2C1', 'R2C2', 'R2C3', 'R2C4'],
@@ -616,7 +614,7 @@ def test_excel_oldindex_format(self):
616614
names=['R0', 'R1'])
617615
si = Index(['R_l0_g0', 'R_l0_g1', 'R_l0_g2', 'R_l0_g3', 'R_l0_g4'], name='R0')
618616

619-
in_file = os.path.join(self.dirpath, 'test_index_name_pre17.xlsx')
617+
in_file = os.path.join(self.dirpath, 'test_index_name_pre17' + self.ext)
620618

621619
expected = pd.DataFrame(data, index=si, columns=columns)
622620
with tm.assert_produces_warning(FutureWarning):

0 commit comments

Comments
 (0)