summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2013-02-21 21:15:40 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2013-02-21 21:15:40 (GMT)
commit7d0eb4b234bacab520104b6c797f69b101baad64 (patch)
tree9ded58f7d93847e8eee2fe0ab3ef6a6eb3eacc91 /Lib
parent49d4022d7d56a027a8be0fc96f58d183bfbc2291 (diff)
downloadcpython-7d0eb4b234bacab520104b6c797f69b101baad64.zip
cpython-7d0eb4b234bacab520104b6c797f69b101baad64.tar.gz
cpython-7d0eb4b234bacab520104b6c797f69b101baad64.tar.bz2
#17255: test short-circuiting behavior of any()/all(). Patch by Wim Glenn.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_builtin.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py
index 28ff74c..b6de524 100644
--- a/Lib/test/test_builtin.py
+++ b/Lib/test/test_builtin.py
@@ -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]