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

Method test_batched

Lib/test/test_itertools.py:2221–2232  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2219 self.assertRaises(ZeroDivisionError, list, accumulate(E(s)))
2220
2221 def test_batched(self):
2222 s = 'abcde'
2223 r = [('a', 'b'), ('c', 'd'), ('e',)]
2224 n = 2
2225 for g in (G, I, Ig, L, R):
2226 with self.subTest(g=g):
2227 self.assertEqual(list(batched(g(s), n)), r)
2228 self.assertEqual(list(batched(S(s), 2)), [])
2229 self.assertRaises(TypeError, batched, X(s), 2)
2230 self.assertRaises(TypeError, batched, N(s), 2)
2231 self.assertRaises(ZeroDivisionError, list, batched(E(s), 2))
2232 self.assertRaises(ZeroDivisionError, list, batched(E2(s), 4))
2233
2234 def test_chain(self):
2235 for s in ("123", "", range(1000), ('do', 1.2), range(2000,2200,5)):

Callers

nothing calls this directly

Calls 10

listClass · 0.85
gFunction · 0.70
SClass · 0.70
XClass · 0.70
NClass · 0.70
EClass · 0.70
E2Class · 0.70
subTestMethod · 0.45
assertEqualMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected