mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
#16559: Add more tests for the json module. Patch by Serhiy Storchaka.
This commit is contained in:
parent
55b4cfb992
commit
282d331ec7
4 changed files with 47 additions and 15 deletions
|
@ -17,6 +17,21 @@ class TestFloat(object):
|
|||
self.assertEqual(self.loads(self.dumps(num)), num)
|
||||
self.assertEqual(self.loads(unicode(self.dumps(num))), num)
|
||||
|
||||
def test_out_of_range(self):
|
||||
self.assertEqual(self.loads('[23456789012E666]'), [float('inf')])
|
||||
self.assertEqual(self.loads('[-23456789012E666]'), [float('-inf')])
|
||||
|
||||
def test_allow_nan(self):
|
||||
for val in (float('inf'), float('-inf'), float('nan')):
|
||||
out = self.dumps([val])
|
||||
if val == val: # inf
|
||||
self.assertEqual(self.loads(out), [val])
|
||||
else: # nan
|
||||
res = self.loads(out)
|
||||
self.assertEqual(len(res), 1)
|
||||
self.assertNotEqual(res[0], res[0])
|
||||
self.assertRaises(ValueError, self.dumps, [val], allow_nan=False)
|
||||
|
||||
|
||||
class TestPyFloat(TestFloat, PyTest): pass
|
||||
class TestCFloat(TestFloat, CTest): pass
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue