From 6a04e42eb518a0c0f17f448949e6571edf9c3be9 Mon Sep 17 00:00:00 2001 From: John Mantios Date: Sun, 3 Jul 2022 17:27:12 +0300 Subject: [PATCH 1/3] TST: added test for to_json when called on numbers that exceed the int64 limit --- pandas/tests/io/json/test_pandas.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pandas/tests/io/json/test_pandas.py b/pandas/tests/io/json/test_pandas.py index eaffbc60ead32..23227f8a97d01 100644 --- a/pandas/tests/io/json/test_pandas.py +++ b/pandas/tests/io/json/test_pandas.py @@ -1908,3 +1908,20 @@ def test_complex_data_tojson(self, data, expected): # GH41174 result = data.to_json() assert result == expected + + @pytest.mark.parametrize( + "data", [{"col1": [13342205958987758245, 12388075603347835679]}] + ) + @pytest.mark.parametrize( + "expected", + [ + '{"columns":["col1"],"index":[0,1],' + '"data":[[13342205958987758245],[12388075603347835679]]}' + ], + ) + @pytest.mark.parametrize("orient", ["split"]) + def test_json_uint64(self, data, expected, orient): + # GH21073 + df = DataFrame(data=data) + result = df.to_json(orient=orient) + assert result == expected From e4487115934221c4918be3e1598a75f130aa94dd Mon Sep 17 00:00:00 2001 From: John Mantios Date: Sun, 3 Jul 2022 20:56:31 +0300 Subject: [PATCH 2/3] TST: removed redundant parametrize wrapper --- pandas/tests/io/json/test_pandas.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/pandas/tests/io/json/test_pandas.py b/pandas/tests/io/json/test_pandas.py index 23227f8a97d01..5d3b1267ab857 100644 --- a/pandas/tests/io/json/test_pandas.py +++ b/pandas/tests/io/json/test_pandas.py @@ -1909,19 +1909,14 @@ def test_complex_data_tojson(self, data, expected): result = data.to_json() assert result == expected - @pytest.mark.parametrize( - "data", [{"col1": [13342205958987758245, 12388075603347835679]}] - ) - @pytest.mark.parametrize( - "expected", - [ + def test_json_uint64(self): + # GH21073 + data = {"col1": [13342205958987758245, 12388075603347835679]} + expected = ( '{"columns":["col1"],"index":[0,1],' '"data":[[13342205958987758245],[12388075603347835679]]}' - ], - ) - @pytest.mark.parametrize("orient", ["split"]) - def test_json_uint64(self, data, expected, orient): - # GH21073 + ) + orient = "split" df = DataFrame(data=data) result = df.to_json(orient=orient) assert result == expected From 57145484f04366b16b128bb7e6e3a2b849ab8768 Mon Sep 17 00:00:00 2001 From: John Mantios Date: Sun, 3 Jul 2022 21:52:19 +0300 Subject: [PATCH 3/3] TST: removed redundant variable declarations --- pandas/tests/io/json/test_pandas.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pandas/tests/io/json/test_pandas.py b/pandas/tests/io/json/test_pandas.py index 5d3b1267ab857..026c3bc68ce34 100644 --- a/pandas/tests/io/json/test_pandas.py +++ b/pandas/tests/io/json/test_pandas.py @@ -1911,12 +1911,10 @@ def test_complex_data_tojson(self, data, expected): def test_json_uint64(self): # GH21073 - data = {"col1": [13342205958987758245, 12388075603347835679]} expected = ( '{"columns":["col1"],"index":[0,1],' '"data":[[13342205958987758245],[12388075603347835679]]}' ) - orient = "split" - df = DataFrame(data=data) - result = df.to_json(orient=orient) + df = DataFrame(data={"col1": [13342205958987758245, 12388075603347835679]}) + result = df.to_json(orient="split") assert result == expected