annotate Lib/test/test_future_builtins.py @ 79675:c0a2294de787 2.7

Issue #16199: Backport 2to3 typo fix from 3.2.
author Chris Jerdonek <chris.jerdonek@gmail.com>
date Thu, 11 Oct 2012 16:15:46 -0700
parents 70e115c34f97
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
45439
8eb598331231 Added future_builtins, which contains PEP 3127 compatible versions of hex() and oct().
Eric Smith <eric@trueblade.com>
parents:
diff changeset
1 import test.test_support, unittest
8eb598331231 Added future_builtins, which contains PEP 3127 compatible versions of hex() and oct().
Eric Smith <eric@trueblade.com>
parents:
diff changeset
2
8eb598331231 Added future_builtins, which contains PEP 3127 compatible versions of hex() and oct().
Eric Smith <eric@trueblade.com>
parents:
diff changeset
3 # we're testing the behavior of these future builtins:
45899
4ca7119d1700 Added zip, map, filter to future_bultins (#2171)
David Wolever <david@wolever.net>
parents: 45439
diff changeset
4 from future_builtins import hex, oct, map, zip, filter
45439
8eb598331231 Added future_builtins, which contains PEP 3127 compatible versions of hex() and oct().
Eric Smith <eric@trueblade.com>
parents:
diff changeset
5
8eb598331231 Added future_builtins, which contains PEP 3127 compatible versions of hex() and oct().
Eric Smith <eric@trueblade.com>
parents:
diff changeset
6 class BuiltinTest(unittest.TestCase):
8eb598331231 Added future_builtins, which contains PEP 3127 compatible versions of hex() and oct().
Eric Smith <eric@trueblade.com>
parents:
diff changeset
7 def test_hex(self):
8eb598331231 Added future_builtins, which contains PEP 3127 compatible versions of hex() and oct().
Eric Smith <eric@trueblade.com>
parents:
diff changeset
8 self.assertEqual(hex(0), '0x0')
8eb598331231 Added future_builtins, which contains PEP 3127 compatible versions of hex() and oct().
Eric Smith <eric@trueblade.com>
parents:
diff changeset
9 self.assertEqual(hex(16), '0x10')
8eb598331231 Added future_builtins, which contains PEP 3127 compatible versions of hex() and oct().
Eric Smith <eric@trueblade.com>
parents:
diff changeset
10 self.assertEqual(hex(16L), '0x10')
8eb598331231 Added future_builtins, which contains PEP 3127 compatible versions of hex() and oct().
Eric Smith <eric@trueblade.com>
parents:
diff changeset
11 self.assertEqual(hex(-16), '-0x10')
8eb598331231 Added future_builtins, which contains PEP 3127 compatible versions of hex() and oct().
Eric Smith <eric@trueblade.com>
parents:
diff changeset
12 self.assertEqual(hex(-16L), '-0x10')
8eb598331231 Added future_builtins, which contains PEP 3127 compatible versions of hex() and oct().
Eric Smith <eric@trueblade.com>
parents:
diff changeset
13 self.assertRaises(TypeError, hex, {})
8eb598331231 Added future_builtins, which contains PEP 3127 compatible versions of hex() and oct().
Eric Smith <eric@trueblade.com>
parents:
diff changeset
14
8eb598331231 Added future_builtins, which contains PEP 3127 compatible versions of hex() and oct().
Eric Smith <eric@trueblade.com>
parents:
diff changeset
15 def test_oct(self):
8eb598331231 Added future_builtins, which contains PEP 3127 compatible versions of hex() and oct().
Eric Smith <eric@trueblade.com>
parents:
diff changeset
16 self.assertEqual(oct(0), '0o0')
8eb598331231 Added future_builtins, which contains PEP 3127 compatible versions of hex() and oct().
Eric Smith <eric@trueblade.com>
parents:
diff changeset
17 self.assertEqual(oct(100), '0o144')
8eb598331231 Added future_builtins, which contains PEP 3127 compatible versions of hex() and oct().
Eric Smith <eric@trueblade.com>
parents:
diff changeset
18 self.assertEqual(oct(100L), '0o144')
8eb598331231 Added future_builtins, which contains PEP 3127 compatible versions of hex() and oct().
Eric Smith <eric@trueblade.com>
parents:
diff changeset
19 self.assertEqual(oct(-100), '-0o144')
8eb598331231 Added future_builtins, which contains PEP 3127 compatible versions of hex() and oct().
Eric Smith <eric@trueblade.com>
parents:
diff changeset
20 self.assertEqual(oct(-100L), '-0o144')
8eb598331231 Added future_builtins, which contains PEP 3127 compatible versions of hex() and oct().
Eric Smith <eric@trueblade.com>
parents:
diff changeset
21 self.assertRaises(TypeError, oct, ())
8eb598331231 Added future_builtins, which contains PEP 3127 compatible versions of hex() and oct().
Eric Smith <eric@trueblade.com>
parents:
diff changeset
22
45899
4ca7119d1700 Added zip, map, filter to future_bultins (#2171)
David Wolever <david@wolever.net>
parents: 45439
diff changeset
23 def test_itertools(self):
4ca7119d1700 Added zip, map, filter to future_bultins (#2171)
David Wolever <david@wolever.net>
parents: 45439
diff changeset
24 from itertools import imap, izip, ifilter
4ca7119d1700 Added zip, map, filter to future_bultins (#2171)
David Wolever <david@wolever.net>
parents: 45439
diff changeset
25 # We will assume that the itertools functions work, so provided
4ca7119d1700 Added zip, map, filter to future_bultins (#2171)
David Wolever <david@wolever.net>
parents: 45439
diff changeset
26 # that we've got identical coppies, we will work!
4ca7119d1700 Added zip, map, filter to future_bultins (#2171)
David Wolever <david@wolever.net>
parents: 45439
diff changeset
27 self.assertEqual(map, imap)
4ca7119d1700 Added zip, map, filter to future_bultins (#2171)
David Wolever <david@wolever.net>
parents: 45439
diff changeset
28 self.assertEqual(zip, izip)
4ca7119d1700 Added zip, map, filter to future_bultins (#2171)
David Wolever <david@wolever.net>
parents: 45439
diff changeset
29 self.assertEqual(filter, ifilter)
4ca7119d1700 Added zip, map, filter to future_bultins (#2171)
David Wolever <david@wolever.net>
parents: 45439
diff changeset
30 # Testing that filter(None, stuff) raises a warning lives in
4ca7119d1700 Added zip, map, filter to future_bultins (#2171)
David Wolever <david@wolever.net>
parents: 45439
diff changeset
31 # test_py3kwarn.py
4ca7119d1700 Added zip, map, filter to future_bultins (#2171)
David Wolever <david@wolever.net>
parents: 45439
diff changeset
32
4ca7119d1700 Added zip, map, filter to future_bultins (#2171)
David Wolever <david@wolever.net>
parents: 45439
diff changeset
33
45439
8eb598331231 Added future_builtins, which contains PEP 3127 compatible versions of hex() and oct().
Eric Smith <eric@trueblade.com>
parents:
diff changeset
34 def test_main(verbose=None):
8eb598331231 Added future_builtins, which contains PEP 3127 compatible versions of hex() and oct().
Eric Smith <eric@trueblade.com>
parents:
diff changeset
35 test.test_support.run_unittest(BuiltinTest)
8eb598331231 Added future_builtins, which contains PEP 3127 compatible versions of hex() and oct().
Eric Smith <eric@trueblade.com>
parents:
diff changeset
36
8eb598331231 Added future_builtins, which contains PEP 3127 compatible versions of hex() and oct().
Eric Smith <eric@trueblade.com>
parents:
diff changeset
37 if __name__ == "__main__":
8eb598331231 Added future_builtins, which contains PEP 3127 compatible versions of hex() and oct().
Eric Smith <eric@trueblade.com>
parents:
diff changeset
38 test_main(verbose=True)