| 511 | |
| 512 | @pytest.mark.parametrize("format", ["csv", "json"]) |
| 513 | def test_codecs_encoding(format, temp_file): |
| 514 | # GH39247 |
| 515 | expected = pd.DataFrame( |
| 516 | 1.1 * np.arange(120).reshape((30, 4)), |
| 517 | columns=pd.Index(list("ABCD")), |
| 518 | index=pd.Index([f"i-{i}" for i in range(30)]), |
| 519 | ) |
| 520 | with open(temp_file, mode="w", encoding="utf-8") as handle: |
| 521 | getattr(expected, f"to_{format}")(handle) |
| 522 | with open(temp_file, encoding="utf-8") as handle: |
| 523 | if format == "csv": |
| 524 | df = pd.read_csv(handle, index_col=0) |
| 525 | else: |
| 526 | df = pd.read_json(handle) |
| 527 | tm.assert_frame_equal(expected, df) |
| 528 | |
| 529 | |
| 530 | def test_codecs_get_writer_reader(temp_file): |