]> granicus.if.org Git - python/commitdiff
#17255: test short-circuiting behavior of any()/all(). Patch by Wim Glenn.
authorEzio Melotti <ezio.melotti@gmail.com>
Thu, 21 Feb 2013 21:15:40 +0000 (23:15 +0200)
committerEzio Melotti <ezio.melotti@gmail.com>
Thu, 21 Feb 2013 21:15:40 +0000 (23:15 +0200)
Lib/test/test_builtin.py
Misc/ACKS

index 28ff74c204a80c89986556eb4f84ab1b3b8ceb5b..b6de524e6c36d7f5b0c41bb1574f6698d88392a5 100644 (file)
@@ -110,6 +110,7 @@ class BuiltinTest(unittest.TestCase):
         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 @@ class BuiltinTest(unittest.TestCase):
         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]
index 94210ef62a129d533f23394615210c5baf4794bd..7574a6a1b1c1b90e090a139812c26cb413e7ef28 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -352,6 +352,7 @@ Dinu Gherman
 Jonathan Giddy
 Johannes Gijsbers
 Michael Gilfix
+Wim Glenn
 Christoph Gohlke
 Tim Golden
 Chris Gonnerman