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