PageRenderTime 203ms CodeModel.GetById 101ms app.highlight 4ms RepoModel.GetById 96ms app.codeStats 0ms

/Lib/test/test_future_builtins.py

http://unladen-swallow.googlecode.com/
Python | 39 lines | 27 code | 7 blank | 5 comment | 1 complexity | 27dddcca199b136832c6d03ecfcae6a7 MD5 | raw file
 1import test.test_support, unittest
 2
 3# we're testing the behavior of these future builtins:
 4from future_builtins import hex, oct, map, zip, filter
 5from test import test_support
 6
 7class 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
35def test_main(verbose=None):
36    test.test_support.run_unittest(BuiltinTest)
37
38if __name__ == "__main__":
39    test_main(verbose=True)