1 import math 2 from json.tests import PyTest, CTest 3 4 5 class TestFloat(object): 6 def test_floats(self): 7 for num in [1617161771.7650001, math.pi, math.pi**100, 8 math.pi**-100, 3.1]: 9 self.assertEqual(float(self.dumps(num)), num) 10 self.assertEqual(self.loads(self.dumps(num)), num) 11 self.assertEqual(self.loads(unicode(self.dumps(num))), num) 12 13 def test_ints(self): 14 for num in [1, 1L, 1<<32, 1<<64]: 15 self.assertEqual(self.dumps(num), str(num)) 16 self.assertEqual(int(self.dumps(num)), num) 17 self.assertEqual(self.loads(self.dumps(num)), num) 18 self.assertEqual(self.loads(unicode(self.dumps(num))), num) 19 20 21 class TestPyFloat(TestFloat, PyTest): pass 22 class TestCFloat(TestFloat, CTest): pass 23