-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Excel Tests Continued Fixture Cleanup #26662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
952ce86
Replaced sparsely used frame2 fixture
WillAyd 620fa19
Cleaned up parametrization and xlrd min skips
WillAyd 417fc30
Decoupled xlrd skips and base reading tests
WillAyd a5d2616
Replaced *args with explicit fixture usage
WillAyd 7fc3f76
Removed unnecessary merge_cells parametrization
WillAyd fd00e51
Merge remote-tracking branch 'upstream/master' into excel-fixture-cle…
WillAyd fd697ea
Merge remote-tracking branch 'upstream/master' into excel-fixture-cle…
WillAyd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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] | ||
|
@@ -58,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]) | ||
|
@@ -844,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') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment might have been lost on a prior PR but the min xlrd version for pandas is 1.0.0 anyway, so this was duplicative |
||
@pytest.mark.parametrize("ext", ['.xls', '.xlsx', '.xlsm']) | ||
class TestRoundTrip: | ||
|
||
|
@@ -1045,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: | ||
simonjayhawkins marked this conversation as resolved.
Show resolved
Hide resolved
|
||
""" | ||
This is the base class for the xlrd tests, and 3 different file formats | ||
are supported: xls, xlsx, xlsm | ||
|
@@ -1149,9 +1143,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 +1314,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 +1325,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) | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that our project-wide minimum ix 1.0.0, so this decorator was being duplicative.
This decorator also won't be there in the long term once we completely couple TestReaders from xlrd, but keeping here for now