From 564793ee9c0c59e7334eefc91a643974a9af856b Mon Sep 17 00:00:00 2001 From: snowman2 Date: Wed, 26 May 2021 08:57:30 -0500 Subject: [PATCH] TST: Add test for non-json serializable attrs --- pandas/tests/io/test_parquet.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pandas/tests/io/test_parquet.py b/pandas/tests/io/test_parquet.py index 15338bea4dc77..e58b9c0c6e09d 100644 --- a/pandas/tests/io/test_parquet.py +++ b/pandas/tests/io/test_parquet.py @@ -929,6 +929,17 @@ def test_read_write_attrs(self, pa): } assert result.b.attrs == {} + @td.skip_if_no("pyarrow") + def test_read_write_attrs__invalid(self, pa): + df = pd.DataFrame({"a": [1], "b": [1]}) + df.attrs = {-1: np.array(1)} + df.a.attrs = {-1: np.array(1)} + df.b.attrs = {} + with tm.ensure_clean() as path, pytest.raises( + TypeError, match="not JSON serializable" + ): + df.to_parquet(path) + class TestParquetFastParquet(Base): def test_basic(self, fp, df_full):