mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	Added future_builtins, which contains PEP 3127 compatible versions of hex() and oct().
This commit is contained in:
		
							parent
							
								
									73d7963242
								
							
						
					
					
						commit
						a73fbe791d
					
				
					 6 changed files with 113 additions and 0 deletions
				
			
		
							
								
								
									
										27
									
								
								Lib/test/test_future_builtins.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								Lib/test/test_future_builtins.py
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,27 @@ | |||
| import test.test_support, unittest | ||||
| 
 | ||||
| # we're testing the behavior of these future builtins: | ||||
| from future_builtins import hex, oct | ||||
| 
 | ||||
| class BuiltinTest(unittest.TestCase): | ||||
|     def test_hex(self): | ||||
|         self.assertEqual(hex(0), '0x0') | ||||
|         self.assertEqual(hex(16), '0x10') | ||||
|         self.assertEqual(hex(16L), '0x10') | ||||
|         self.assertEqual(hex(-16), '-0x10') | ||||
|         self.assertEqual(hex(-16L), '-0x10') | ||||
|         self.assertRaises(TypeError, hex, {}) | ||||
| 
 | ||||
|     def test_oct(self): | ||||
|         self.assertEqual(oct(0), '0o0') | ||||
|         self.assertEqual(oct(100), '0o144') | ||||
|         self.assertEqual(oct(100L), '0o144') | ||||
|         self.assertEqual(oct(-100), '-0o144') | ||||
|         self.assertEqual(oct(-100L), '-0o144') | ||||
|         self.assertRaises(TypeError, oct, ()) | ||||
| 
 | ||||
| def test_main(verbose=None): | ||||
|     test.test_support.run_unittest(BuiltinTest) | ||||
| 
 | ||||
| if __name__ == "__main__": | ||||
|     test_main(verbose=True) | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Eric Smith
						Eric Smith