Commits

Ezio Melotti committed 34b7240

#17255: test short-circuiting behavior of any()/all(). Patch by Wim Glenn.

  • Participants
  • Parent commits 36220cf
  • Branches 3.2

Comments (0)

Files changed (2)

Lib/test/test_builtin.py

         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]
         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]
 Johannes Gijsbers
 Michael Gilfix
 Matt Giuca
+Wim Glenn
 Christoph Gohlke
 Tim Golden
 Guilherme Gonçalves