We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ddb3786 commit 8a38261Copy full SHA for 8a38261
Lib/test/test_json/test_dump.py
@@ -57,6 +57,21 @@ def __lt__(self, o):
57
d[1337] = "true.dat"
58
self.assertEqual(self.dumps(d, sort_keys=True), '{"1337": "true.dat"}')
59
60
+ # Issue 36841
61
+ def test_encode_float(self):
62
+ data = {0.88: 0.9, 0: 0.1}
63
+ expected = '{"0.88": 0.9, "0": 0.1}'
64
+ self.assertEqual(
65
+ self.dumps(data, encode_float=None),
66
+ expected
67
+ )
68
+
69
70
+ expected = '{"1": 1, "0": 0}'
71
72
+ self.dumps(data, encode_float=lambda x: str(round(x))),
73
74
75
76
class TestPyDump(TestDump, PyTest): pass
77
0 commit comments