diff --git a/pandas/tests/io/test_common.py b/pandas/tests/io/test_common.py index 145682b484100..5b3b5602c95bc 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"