mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 23:21:29 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			15 lines
		
	
	
	
		
			447 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			15 lines
		
	
	
	
		
			447 B
		
	
	
	
		
			Python
		
	
	
	
	
	
import decimal
 | 
						|
from unittest import TestCase
 | 
						|
 | 
						|
import json
 | 
						|
 | 
						|
class TestDecode(TestCase):
 | 
						|
    def test_decimal(self):
 | 
						|
        rval = json.loads('1.1', parse_float=decimal.Decimal)
 | 
						|
        self.assert_(isinstance(rval, decimal.Decimal))
 | 
						|
        self.assertEquals(rval, decimal.Decimal('1.1'))
 | 
						|
 | 
						|
    def test_float(self):
 | 
						|
        rval = json.loads('1', parse_int=float)
 | 
						|
        self.assert_(isinstance(rval, float))
 | 
						|
        self.assertEquals(rval, 1.0)
 |