PageRenderTime 43ms CodeModel.GetById 20ms app.highlight 7ms RepoModel.GetById 13ms app.codeStats 0ms

/Lib/json/tests/test_decode.py

http://unladen-swallow.googlecode.com/
Python | 15 lines | 12 code | 3 blank | 0 comment | 0 complexity | 4647e8112a9fa83b7fc3c86d519eef33 MD5 | raw file
 1import decimal
 2from unittest import TestCase
 3
 4import json
 5
 6class TestDecode(TestCase):
 7    def test_decimal(self):
 8        rval = json.loads('1.1', parse_float=decimal.Decimal)
 9        self.assert_(isinstance(rval, decimal.Decimal))
10        self.assertEquals(rval, decimal.Decimal('1.1'))
11
12    def test_float(self):
13        rval = json.loads('1', parse_int=float)
14        self.assert_(isinstance(rval, float))
15        self.assertEquals(rval, 1.0)