annotate Lib/json/tests/test_float.py @ 79675:c0a2294de787 2.7

Issue #16199: Backport 2to3 typo fix from 3.2.
author Chris Jerdonek <chris.jerdonek@gmail.com>
date Thu, 11 Oct 2012 16:15:46 -0700
parents 5b0fecd2eba0
children e092ff374721
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
46676
4ded35754cb7 Add the 'json' package. Code taken from simplejson 1.9 and contributed by Bob
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
1 import math
70084
5b0fecd2eba0 #5723: Improve json tests to be executed with and without accelerations.
Ezio Melotti <ezio.melotti@gmail.com>
parents: 66348
diff changeset
2 from json.tests import PyTest, CTest
46676
4ded35754cb7 Add the 'json' package. Code taken from simplejson 1.9 and contributed by Bob
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
3
4ded35754cb7 Add the 'json' package. Code taken from simplejson 1.9 and contributed by Bob
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
4
70084
5b0fecd2eba0 #5723: Improve json tests to be executed with and without accelerations.
Ezio Melotti <ezio.melotti@gmail.com>
parents: 66348
diff changeset
5 class TestFloat(object):
46676
4ded35754cb7 Add the 'json' package. Code taken from simplejson 1.9 and contributed by Bob
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
6 def test_floats(self):
52427
685f1791fbc5 Issue 5381: fix regression in pure python code path, Issue 5584: fix a decoder bug for unicode float literals outside of a container
Bob Ippolito <bob@redivi.com>
parents: 52199
diff changeset
7 for num in [1617161771.7650001, math.pi, math.pi**100,
685f1791fbc5 Issue 5381: fix regression in pure python code path, Issue 5584: fix a decoder bug for unicode float literals outside of a container
Bob Ippolito <bob@redivi.com>
parents: 52199
diff changeset
8 math.pi**-100, 3.1]:
70084
5b0fecd2eba0 #5723: Improve json tests to be executed with and without accelerations.
Ezio Melotti <ezio.melotti@gmail.com>
parents: 66348
diff changeset
9 self.assertEqual(float(self.dumps(num)), num)
5b0fecd2eba0 #5723: Improve json tests to be executed with and without accelerations.
Ezio Melotti <ezio.melotti@gmail.com>
parents: 66348
diff changeset
10 self.assertEqual(self.loads(self.dumps(num)), num)
5b0fecd2eba0 #5723: Improve json tests to be executed with and without accelerations.
Ezio Melotti <ezio.melotti@gmail.com>
parents: 66348
diff changeset
11 self.assertEqual(self.loads(unicode(self.dumps(num))), num)
52199
d95e5add3ca4 merge json library with simplejson 2.0.9 (issue 4136)
Bob Ippolito <bob@redivi.com>
parents: 46676
diff changeset
12
d95e5add3ca4 merge json library with simplejson 2.0.9 (issue 4136)
Bob Ippolito <bob@redivi.com>
parents: 46676
diff changeset
13 def test_ints(self):
d95e5add3ca4 merge json library with simplejson 2.0.9 (issue 4136)
Bob Ippolito <bob@redivi.com>
parents: 46676
diff changeset
14 for num in [1, 1L, 1<<32, 1<<64]:
70084
5b0fecd2eba0 #5723: Improve json tests to be executed with and without accelerations.
Ezio Melotti <ezio.melotti@gmail.com>
parents: 66348
diff changeset
15 self.assertEqual(self.dumps(num), str(num))
5b0fecd2eba0 #5723: Improve json tests to be executed with and without accelerations.
Ezio Melotti <ezio.melotti@gmail.com>
parents: 66348
diff changeset
16 self.assertEqual(int(self.dumps(num)), num)
5b0fecd2eba0 #5723: Improve json tests to be executed with and without accelerations.
Ezio Melotti <ezio.melotti@gmail.com>
parents: 66348
diff changeset
17 self.assertEqual(self.loads(self.dumps(num)), num)
5b0fecd2eba0 #5723: Improve json tests to be executed with and without accelerations.
Ezio Melotti <ezio.melotti@gmail.com>
parents: 66348
diff changeset
18 self.assertEqual(self.loads(unicode(self.dumps(num))), num)
5b0fecd2eba0 #5723: Improve json tests to be executed with and without accelerations.
Ezio Melotti <ezio.melotti@gmail.com>
parents: 66348
diff changeset
19
5b0fecd2eba0 #5723: Improve json tests to be executed with and without accelerations.
Ezio Melotti <ezio.melotti@gmail.com>
parents: 66348
diff changeset
20
5b0fecd2eba0 #5723: Improve json tests to be executed with and without accelerations.
Ezio Melotti <ezio.melotti@gmail.com>
parents: 66348
diff changeset
21 class TestPyFloat(TestFloat, PyTest): pass
5b0fecd2eba0 #5723: Improve json tests to be executed with and without accelerations.
Ezio Melotti <ezio.melotti@gmail.com>
parents: 66348
diff changeset
22 class TestCFloat(TestFloat, CTest): pass