summaryrefslogtreecommitdiffstats
path: root/Lib/test
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)
commit0f4377c100049a80d2338de3b9f3b7c7489a08b3 (patch)
tree31a6822c0e7c447b8dc6a55f3733102f152699cd /Lib/test
parentc510a048ba4f17a82fff0a452bf9ccd29b51efc6 (diff)
downloadcpython-0f4377c100049a80d2338de3b9f3b7c7489a08b3.zip
cpython-0f4377c100049a80d2338de3b9f3b7c7489a08b3.tar.gz
cpython-0f4377c100049a80d2338de3b9f3b7c7489a08b3.tar.bz2
#17255: test short-circuiting behavior of any()/all(). Patch by Wim Glenn.
Diffstat (limited to 'Lib/test')
-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 42a1e35..f4d3400 100644
--- a/Lib/test/test_builtin.py
+++ b/Lib/test/test_builtin.py
@@ -155,6 +155,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]
@@ -169,6 +170,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]