annotate Lib/test/test_future_builtins.py @ 58925:eecf1bef052d 2.6

Merged revisions 78207 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r78207 | ezio.melotti | 2010-02-17 01:26:09 +0200 (Wed, 17 Feb 2010) | 1 line #7930: fix stripid ........
author Ezio Melotti <ezio.melotti@gmail.com>
date Tue, 16 Feb 2010 23:29:44 +0000
parents 4ca7119d1700
children 70e115c34f97
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
4ca7119d1700 Added zip, map, filter to future_bultins (#2171)
David Wolever <david@wolever.net>
parents: 45439
diff changeset
5 from test import test_support
45439
8eb598331231 Added future_builtins, which contains PEP 3127 compatible versions of hex() and oct().
Eric Smith <eric@trueblade.com>
parents:
diff changeset
6
8eb598331231 Added future_builtins, which contains PEP 3127 compatible versions of hex() and oct().
Eric Smith <eric@trueblade.com>
parents:
diff changeset
7 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
8 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
9 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
10 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
11 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
12 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
13 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
14 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
15
8eb598331231 Added future_builtins, which contains PEP 3127 compatible versions of hex() and oct().
Eric Smith <eric@trueblade.com>
parents:
diff changeset
16 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
17 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
18 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
19 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
20 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
21 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
22 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
23
45899
4ca7119d1700 Added zip, map, filter to future_bultins (#2171)
David Wolever <david@wolever.net>
parents: 45439
diff changeset
24 def test_itertools(self):
4ca7119d1700 Added zip, map, filter to future_bultins (#2171)
David Wolever <david@wolever.net>
parents: 45439
diff changeset
25 from itertools import imap, izip, ifilter
4ca7119d1700 Added zip, map, filter to future_bultins (#2171)
David Wolever <david@wolever.net>
parents: 45439
diff changeset
26 # 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
27 # 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
28 self.assertEqual(map, imap)
4ca7119d1700 Added zip, map, filter to future_bultins (#2171)
David Wolever <david@wolever.net>
parents: 45439
diff changeset
29 self.assertEqual(zip, izip)
4ca7119d1700 Added zip, map, filter to future_bultins (#2171)
David Wolever <david@wolever.net>
parents: 45439
diff changeset
30 self.assertEqual(filter, ifilter)
4ca7119d1700 Added zip, map, filter to future_bultins (#2171)
David Wolever <david@wolever.net>
parents: 45439
diff changeset
31 # 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
32 # test_py3kwarn.py
4ca7119d1700 Added zip, map, filter to future_bultins (#2171)
David Wolever <david@wolever.net>
parents: 45439
diff changeset
33
4ca7119d1700 Added zip, map, filter to future_bultins (#2171)
David Wolever <david@wolever.net>
parents: 45439
diff changeset
34
45439
8eb598331231 Added future_builtins, which contains PEP 3127 compatible versions of hex() and oct().
Eric Smith <eric@trueblade.com>
parents:
diff changeset
35 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
36 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
37
8eb598331231 Added future_builtins, which contains PEP 3127 compatible versions of hex() and oct().
Eric Smith <eric@trueblade.com>
parents:
diff changeset
38 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
39 test_main(verbose=True)