diff options
author | David Wolever <david@wolever.net> | 2008-03-19 02:35:45 (GMT) |
---|---|---|
committer | David Wolever <david@wolever.net> | 2008-03-19 02:35:45 (GMT) |
commit | 2724ab99c8c81cdb032372871d8f1eebb171ebe7 (patch) | |
tree | 536d452a552c67fc395e7049db451df5ee296eaa /Lib | |
parent | fbe7c559054e33a74a330462aa8ae0682910a414 (diff) | |
download | cpython-2724ab99c8c81cdb032372871d8f1eebb171ebe7.zip cpython-2724ab99c8c81cdb032372871d8f1eebb171ebe7.tar.gz cpython-2724ab99c8c81cdb032372871d8f1eebb171ebe7.tar.bz2 |
Added zip, map, filter to future_bultins (#2171)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_future_builtins.py | 14 | ||||
-rw-r--r-- | Lib/test/test_py3kwarn.py | 11 |
2 files changed, 24 insertions, 1 deletions
diff --git a/Lib/test/test_future_builtins.py b/Lib/test/test_future_builtins.py index 69e719b..0e16caf 100644 --- a/Lib/test/test_future_builtins.py +++ b/Lib/test/test_future_builtins.py @@ -1,7 +1,8 @@ import test.test_support, unittest # we're testing the behavior of these future builtins: -from future_builtins import hex, oct +from future_builtins import hex, oct, map, zip, filter +from test import test_support class BuiltinTest(unittest.TestCase): def test_hex(self): @@ -20,6 +21,17 @@ class BuiltinTest(unittest.TestCase): self.assertEqual(oct(-100L), '-0o144') self.assertRaises(TypeError, oct, ()) + def test_itertools(self): + from itertools import imap, izip, ifilter + # We will assume that the itertools functions work, so provided + # that we've got identical coppies, we will work! + self.assertEqual(map, imap) + self.assertEqual(zip, izip) + self.assertEqual(filter, ifilter) + # Testing that filter(None, stuff) raises a warning lives in + # test_py3kwarn.py + + def test_main(verbose=None): test.test_support.run_unittest(BuiltinTest) diff --git a/Lib/test/test_py3kwarn.py b/Lib/test/test_py3kwarn.py index cdb1038..cc1e9f4 100644 --- a/Lib/test/test_py3kwarn.py +++ b/Lib/test/test_py3kwarn.py @@ -50,6 +50,17 @@ class TestPy3KWarnings(unittest.TestCase): with catch_warning() as w: self.assertWarning(cell0 < cell1, w, expected) + def test_filter(self): + from itertools import ifilter + from future_builtins import filter + expected = 'ifilter with None as a first argument is not supported '\ + 'in 3.x. Use a list comprehension instead.' + + with catch_warning() as w: + self.assertWarning(ifilter(None, []), w, expected) + with catch_warning() as w: + self.assertWarning(filter(None, []), w, expected) + def test_code_inequality_comparisons(self): expected = 'code inequality comparisons not supported in 3.x.' def f(x): |