def test_unsuitableRange(self): self.assertEqual(list(iterage.chunk(range(8), 3)), [(0, 1, 2), (3, 4, 5), (6, 7)]) self.assertEqual(list(iterage.chunk(range(1), 3)), [(0,)])
def test_simpleUseCases(self): self.assertEqual(list(iterage.chunk(range(9), 3)), [(0, 1, 2), (3, 4, 5), (6, 7, 8)]) self.assertEqual(list(iterage.chunk(range(3), 3)), [(0, 1, 2)]) self.assertEqual(list(iterage.chunk(iter([0, 1, 2]), 3)), [(0, 1, 2)])
def test_emptyRange(self): self.assertEqual(list(iterage.chunk(range(0), 3)), []) self.assertEqual(list(iterage.chunk((), 3)), [])
def chunk(self, n: int) -> "Itr[Sequence[T]]": return self.__class__(chunk(self._itr, n))