MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_all

Method test_all

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected