Skip to content

Commit

Permalink
Fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Tolker-KU committed Jan 12, 2025
1 parent 9e12fac commit 21f2689
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 22 deletions.
4 changes: 2 additions & 2 deletions pandas/tests/io/json/test_json_table_schema_ext_dtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def test_build_decimal_series(self, dc):
expected = OrderedDict(
[
("schema", schema),
("data", [OrderedDict([("id", 0), ("a", 10.0)])]),
("data", [OrderedDict([("id", 0), ("a", "10")])]),
]
)

Expand Down Expand Up @@ -245,7 +245,7 @@ def test_to_json(self, da, dc, sa, ia):
[
("idx", 0),
("A", "2021-10-10T00:00:00.000"),
("B", 10.0),
("B", "10"),
("C", "pandas"),
("D", 10),
]
Expand Down
6 changes: 1 addition & 5 deletions pandas/tests/io/json/test_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -2025,12 +2025,8 @@ def test_to_s3(self, s3_public_bucket, s3so):
timeout -= 0.1
assert timeout > 0, "Timed out waiting for file to appear on moto"

def test_json_pandas_nulls(self, nulls_fixture, request):
def test_json_pandas_nulls(self, nulls_fixture):
# GH 31615
if isinstance(nulls_fixture, Decimal):
mark = pytest.mark.xfail(reason="not implemented")
request.applymarker(mark)

expected_warning = None
msg = (
"The default 'epoch' date format is deprecated and will be removed "
Expand Down
30 changes: 15 additions & 15 deletions pandas/tests/io/json/test_ujson.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,56 +57,56 @@ def test_encode_decimal(self):
sut = decimal.Decimal("1337.1337")
encoded = ujson.ujson_dumps(sut, double_precision=15)
decoded = ujson.ujson_loads(encoded)
assert decoded == 1337.1337
assert decoded == "1337.1337"

sut = decimal.Decimal("0.95")
encoded = ujson.ujson_dumps(sut, double_precision=1)
assert encoded == "1.0"
assert encoded == '"0.95"'

decoded = ujson.ujson_loads(encoded)
assert decoded == 1.0
assert decoded == "0.95"

sut = decimal.Decimal("0.94")
encoded = ujson.ujson_dumps(sut, double_precision=1)
assert encoded == "0.9"
assert encoded == '"0.94"'

decoded = ujson.ujson_loads(encoded)
assert decoded == 0.9
assert decoded == "0.94"

sut = decimal.Decimal("1.95")
encoded = ujson.ujson_dumps(sut, double_precision=1)
assert encoded == "2.0"
assert encoded == '"1.95"'

decoded = ujson.ujson_loads(encoded)
assert decoded == 2.0
assert decoded == "1.95"

sut = decimal.Decimal("-1.95")
encoded = ujson.ujson_dumps(sut, double_precision=1)
assert encoded == "-2.0"
assert encoded == '"-1.95"'

decoded = ujson.ujson_loads(encoded)
assert decoded == -2.0
assert decoded == "-1.95"

sut = decimal.Decimal("0.995")
encoded = ujson.ujson_dumps(sut, double_precision=2)
assert encoded == "1.0"
assert encoded == '"0.995"'

decoded = ujson.ujson_loads(encoded)
assert decoded == 1.0
assert decoded == "0.995"

sut = decimal.Decimal("0.9995")
encoded = ujson.ujson_dumps(sut, double_precision=3)
assert encoded == "1.0"
assert encoded == '"0.9995"'

decoded = ujson.ujson_loads(encoded)
assert decoded == 1.0
assert decoded == "0.9995"

sut = decimal.Decimal("0.99999999999999944")
encoded = ujson.ujson_dumps(sut, double_precision=15)
assert encoded == "1.0"
assert encoded == '"0.99999999999999944"'

decoded = ujson.ujson_loads(encoded)
assert decoded == 1.0
assert decoded == "0.99999999999999944"

@pytest.mark.parametrize("ensure_ascii", [True, False])
def test_encode_string_conversion(self, ensure_ascii):
Expand Down

0 comments on commit 21f2689

Please sign in to comment.