def test_length_hint(self):
lh = operator.length_hint
s = struct.Struct('>IB')
b = bytes(range(1, 16))
it = s.iter_unpack(b)
self.assertEqual(lh(it), 3)
next(it)
self.assertEqual(lh(it), 2)
next(it)
self.assertEqual(lh(it), 1)
next(it)
self.assertEqual(lh(it), 0)
self.assertRaises(StopIteration, next, it)
self.assertEqual(lh(it), 0)
评论列表
文章目录