MCPcopy Index your code
hub / github.com/python/cpython / test_all

Method test_all

Lib/test/test_builtin.py:215–230  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

213 self.assertEqual(abs(AbsClass()), -5)
214
215 def test_all(self):
216 self.assertEqual(all([2, 4, 6]), True)
217 self.assertEqual(all([2, None, 6]), False)
218 self.assertRaises(RuntimeError, all, [2, TestFailingBool(), 6])
219 self.assertRaises(RuntimeError, all, TestFailingIter())
220 self.assertRaises(TypeError, all, 10) # Non-iterable
221 self.assertRaises(TypeError, all) # No args
222 self.assertRaises(TypeError, all, [2, 4, 6], []) # Too many args
223 self.assertEqual(all([]), True) # Empty iterator
224 self.assertEqual(all([0, TestFailingBool()]), False)# Short-circuit
225 S = [50, 60]
226 self.assertEqual(all(x > 42 for x in S), True)
227 S = [50, 40, 60]
228 self.assertEqual(all(x > 42 for x in S), False)
229 S = [50, 40, 60, TestFailingBool()]
230 self.assertEqual(all(x > 42 for x in S), False)
231
232 def test_any(self):
233 self.assertEqual(any([None, None, None]), False)

Callers

nothing calls this directly

Calls 4

TestFailingBoolClass · 0.85
TestFailingIterClass · 0.70
assertEqualMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected