"""Test module for itertools_utils.""" import types import pytest from feed_ingestion.util import itertools_utils @pytest.mark.parametrize( 'iterable, batch_size, expected_result', [ [ [1, 1, 1, 2, 2, 2, 3, 3], 2, [[1, 1], [1, 2], [2, 2], [3, 3]] ], [ [1, 1, 1, 2, 2, 2, 3, 3], 3, [[1, 1, 1], [2, 2, 2], [3, 3]] ], ] ) def test_batched(iterable, batch_size, expected_result): result = itertools_utils.batched(iterable=iterable, n=batch_size) assert isinstance(result, types.GeneratorType) result = list(result) assert result == expected_result