[Python-checkins] cpython (2.7): #17255: test short-circuiting behavior of any()/all(). Patch by Wim Glenn.

ezio.melotti python-checkins at python.org
Thu Feb 21 22:17:49 CET 2013


http://hg.python.org/cpython/rev/124237eb5de9
changeset:   82304:124237eb5de9
branch:      2.7
parent:      82300:ce583eb0bec2
user:        Ezio Melotti <ezio.melotti at gmail.com>
date:        Thu Feb 21 23:15:40 2013 +0200
summary:
  #17255: test short-circuiting behavior of any()/all().  Patch by Wim Glenn.

files:
  Lib/test/test_builtin.py |  2 ++
  Misc/ACKS                |  1 +
  2 files changed, 3 insertions(+), 0 deletions(-)


diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py
--- a/Lib/test/test_builtin.py
+++ b/Lib/test/test_builtin.py
@@ -110,6 +110,7 @@
         self.assertRaises(TypeError, all)                   # No args
         self.assertRaises(TypeError, all, [2, 4, 6], [])    # Too many args
         self.assertEqual(all([]), True)                     # Empty iterator
+        self.assertEqual(all([0, TestFailingBool()]), False)# Short-circuit
         S = [50, 60]
         self.assertEqual(all(x > 42 for x in S), True)
         S = [50, 40, 60]
@@ -124,6 +125,7 @@
         self.assertRaises(TypeError, any)                   # No args
         self.assertRaises(TypeError, any, [2, 4, 6], [])    # Too many args
         self.assertEqual(any([]), False)                    # Empty iterator
+        self.assertEqual(any([1, TestFailingBool()]), True) # Short-circuit
         S = [40, 60, 30]
         self.assertEqual(any(x > 42 for x in S), True)
         S = [10, 20, 30]
diff --git a/Misc/ACKS b/Misc/ACKS
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -352,6 +352,7 @@
 Jonathan Giddy
 Johannes Gijsbers
 Michael Gilfix
+Wim Glenn
 Christoph Gohlke
 Tim Golden
 Chris Gonnerman

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list