Skip to content

CI: Change flaky to_excel test to use xlsxwriter #49509

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 7 commits into from
Nov 9, 2022
18 changes: 11 additions & 7 deletions pandas/tests/io/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,14 +359,18 @@ def test_write_fspath_all(self, writer_name, writer_kwargs, module):
writer = getattr(df, writer_name)

writer(string, **writer_kwargs)
with open(string, "rb") as f:
expected = f.read()

writer(mypath, **writer_kwargs)
with open(fspath, "rb") as f:
result = f.read()

assert result == expected
with open(string, "rb") as f_str, open(fspath, "rb") as f_path:
if writer == "to_excel":
# binary representation of excel contains time creation
# data that causes flaky CI failures
result = pd.read_excel(f_str, **writer_kwargs)
expected = pd.read_excel(f_path, **writer_kwargs)
tm.assert_frame_equal(result, expected)
else:
result = f_str.read()
expected = f_path.read()
assert result == expected

@pytest.mark.filterwarnings( # pytables np.object usage
"ignore:`np.object` is a deprecated alias:DeprecationWarning"
Expand Down