home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 June / maximum-cd-2011-06.iso / DiscContents / LibO_3.3.1_Win_x86_install_multi.exe / libreoffice1.cab / test_future_builtins.py < prev    next >
Encoding:
Python Source  |  2011-02-15  |  1.3 KB  |  40 lines

  1. import test.test_support, unittest
  2.  
  3. # we're testing the behavior of these future builtins:
  4. from future_builtins import hex, oct, map, zip, filter
  5. from test import test_support
  6.  
  7. class BuiltinTest(unittest.TestCase):
  8.     def test_hex(self):
  9.         self.assertEqual(hex(0), '0x0')
  10.         self.assertEqual(hex(16), '0x10')
  11.         self.assertEqual(hex(16L), '0x10')
  12.         self.assertEqual(hex(-16), '-0x10')
  13.         self.assertEqual(hex(-16L), '-0x10')
  14.         self.assertRaises(TypeError, hex, {})
  15.  
  16.     def test_oct(self):
  17.         self.assertEqual(oct(0), '0o0')
  18.         self.assertEqual(oct(100), '0o144')
  19.         self.assertEqual(oct(100L), '0o144')
  20.         self.assertEqual(oct(-100), '-0o144')
  21.         self.assertEqual(oct(-100L), '-0o144')
  22.         self.assertRaises(TypeError, oct, ())
  23.  
  24.     def test_itertools(self):
  25.         from itertools import imap, izip, ifilter
  26.         # We will assume that the itertools functions work, so provided
  27.         # that we've got identical coppies, we will work!
  28.         self.assertEqual(map, imap)
  29.         self.assertEqual(zip, izip)
  30.         self.assertEqual(filter, ifilter)
  31.         # Testing that filter(None, stuff) raises a warning lives in
  32.         # test_py3kwarn.py
  33.  
  34.  
  35. def test_main(verbose=None):
  36.     test.test_support.run_unittest(BuiltinTest)
  37.  
  38. if __name__ == "__main__":
  39.     test_main(verbose=True)
  40.