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