import pytest from funcy import rcompose, chunks def test_rcompose(): f = rcompose(lambda x: x ** 2, str, lambda x: x * 2) assert f(3) == "99" def test_chunk_iterable_exact_split(): a, b = chunks(5, iter(range(10))) assert a == list(range(5)) assert b == list(range(5, 10)) def test_chunk_iterable_no_split(): a = next(chunks(10, iter(range(10)))) assert a == list(range(10)) def test_chunk_iterable_last_partial(): a, b, c, d = chunks(3, iter(range(10))) assert d == [9] def test_chunk_iterable_empty(): with pytest.raises(StopIteration): next(chunks(3, iter(range(0)))) def test_chunk_iterable_less_than_chunk_size_elements(): assert next(chunks(5, iter(range(2)))) == [0, 1]