Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(746)

Side by Side Diff: Lib/json/tests/test_decode.py

Issue 7311: [issue4136] merge json library with simplejson 2.0.3 Base URL: http://svn.python.org/view/*checkout*/python/trunk/
Patch Set: Created 5 years, 6 months ago , Downloaded from: http://bugs.python.org/file11822/json_issue4136_r66961.diff
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 import decimal 1 import decimal
2 from unittest import TestCase 2 from unittest import TestCase
3 3
4 import json 4 import json
5 5
6 class TestDecode(TestCase): 6 class TestDecode(TestCase):
7 def test_decimal(self): 7 def test_decimal(self):
8 rval = json.loads('1.1', parse_float=decimal.Decimal) 8 rval = json.loads('1.1', parse_float=decimal.Decimal)
9 self.assert_(isinstance(rval, decimal.Decimal)) 9 self.assert_(isinstance(rval, decimal.Decimal))
10 self.assertEquals(rval, decimal.Decimal('1.1')) 10 self.assertEquals(rval, decimal.Decimal('1.1'))
11 11
12 def test_float(self): 12 def test_float(self):
13 rval = json.loads('1', parse_int=float) 13 rval = json.loads('1', parse_int=float)
14 self.assert_(isinstance(rval, float)) 14 self.assert_(isinstance(rval, float))
15 self.assertEquals(rval, 1.0) 15 self.assertEquals(rval, 1.0)
16
17 def test_decoder_optimizations(self):
18 # Several optimizations were made that skip over calls to
19 # the whitespace regex, so this test is designed to try and
20 # exercise the uncommon cases. The array cases are already covered.
21 rval = json.loads('{ "key" : "value" , "k":"v" }')
22 self.assertEquals(rval, {"key":"value", "k":"v"})
OLDNEW

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld 1278:e6ce13d99bf5