From 2072ec183b06a45d0760cc6b957298fa2898926a Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Thu, 3 Nov 2022 14:10:52 -0700 Subject: [PATCH 1/3] CI: Change flaky to_excel test to use xlsxwriter --- pandas/tests/io/test_common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/io/test_common.py b/pandas/tests/io/test_common.py index 145682b484100..96ff900bbe1f9 100644 --- a/pandas/tests/io/test_common.py +++ b/pandas/tests/io/test_common.py @@ -339,7 +339,7 @@ def test_read_fspath_all(self, reader, module, path, datapath): "writer_name, writer_kwargs, module", [ ("to_csv", {}, "os"), - ("to_excel", {"engine": "openpyxl"}, "openpyxl"), + ("to_excel", {"engine": "xlsxwriter"}, "xlsxwriter"), ("to_feather", {}, "pyarrow"), ("to_html", {}, "os"), ("to_json", {}, "os"), From 1f692297dc2e814486de6230cdf4dbcc9799f7a7 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Mon, 7 Nov 2022 13:27:05 -0800 Subject: [PATCH 2/3] Just commpare df --- pandas/tests/io/test_common.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/pandas/tests/io/test_common.py b/pandas/tests/io/test_common.py index 96ff900bbe1f9..f5fb726954929 100644 --- a/pandas/tests/io/test_common.py +++ b/pandas/tests/io/test_common.py @@ -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" From ce43179fc755bfc5d14cb96455f00632fd30e12a Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Mon, 7 Nov 2022 19:47:01 -0800 Subject: [PATCH 3/3] Back to openpyxl --- pandas/tests/io/test_common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/io/test_common.py b/pandas/tests/io/test_common.py index f5fb726954929..5b3b5602c95bc 100644 --- a/pandas/tests/io/test_common.py +++ b/pandas/tests/io/test_common.py @@ -339,7 +339,7 @@ def test_read_fspath_all(self, reader, module, path, datapath): "writer_name, writer_kwargs, module", [ ("to_csv", {}, "os"), - ("to_excel", {"engine": "xlsxwriter"}, "xlsxwriter"), + ("to_excel", {"engine": "openpyxl"}, "openpyxl"), ("to_feather", {}, "pyarrow"), ("to_html", {}, "os"), ("to_json", {}, "os"),