| 1348 | tm.assert_frame_equal(df, reread_df) |
| 1349 | |
| 1350 | def test_engine_kwargs(self, engine, tmp_excel): |
| 1351 | # GH#52368 |
| 1352 | df = DataFrame([{"A": 1, "B": 2}, {"A": 3, "B": 4}]) |
| 1353 | |
| 1354 | msgs = { |
| 1355 | "odf": r"OpenDocumentSpreadsheet() got an unexpected keyword " |
| 1356 | r"argument 'foo'", |
| 1357 | "openpyxl": r"__init__() got an unexpected keyword argument 'foo'", |
| 1358 | "xlsxwriter": r"__init__() got an unexpected keyword argument 'foo'", |
| 1359 | } |
| 1360 | |
| 1361 | msgs["openpyxl"] = ( |
| 1362 | "Workbook.__init__() got an unexpected keyword argument 'foo'" |
| 1363 | ) |
| 1364 | msgs["xlsxwriter"] = ( |
| 1365 | "Workbook.__init__() got an unexpected keyword argument 'foo'" |
| 1366 | ) |
| 1367 | |
| 1368 | # Handle change in error message for openpyxl (write and append mode) |
| 1369 | if engine == "openpyxl" and not os.path.exists(tmp_excel): |
| 1370 | msgs["openpyxl"] = ( |
| 1371 | r"load_workbook() got an unexpected keyword argument 'foo'" |
| 1372 | ) |
| 1373 | |
| 1374 | with pytest.raises(TypeError, match=re.escape(msgs[engine])): |
| 1375 | df.to_excel( |
| 1376 | tmp_excel, |
| 1377 | engine=engine, |
| 1378 | engine_kwargs={"foo": "bar"}, |
| 1379 | ) |
| 1380 | |
| 1381 | def test_write_lists_dict(self, tmp_excel): |
| 1382 | # see gh-8188. |