import typing as tp
from unittest import TestCase

import hypothesis as hp
from hypothesis import strategies as st
import pypeln as pl
import cytoolz as cz

MAX_EXAMPLES = 10
T = tp.TypeVar("T")


@hp.given(nums=st.lists(st.integers()))
@hp.settings(max_examples=MAX_EXAMPLES)
def test_from_to_iterable(nums: tp.List[int]):

    nums_pl = nums
    nums_pl = pl.thread.from_iterable(nums_pl)
    nums_pl = cz.partition_all(10, nums_pl)
    nums_pl = pl.thread.map(sum, nums_pl)
    nums_pl = pl.thread.to_iterable(nums_pl)
    nums_pl = list(nums_pl)

    nums_py = nums
    nums_py = cz.partition_all(10, nums_py)
    nums_py = map(sum, nums_py)
    nums_py = list(nums_py)

    assert nums_py == nums_pl

[((179, 194), 'typing.TypeVar', 'tp.TypeVar', (['"""T"""'], {}), "('T')\n", (189, 194), True, 'import typing as tp\n'), ((238, 276), 'hypothesis.settings', 'hp.settings', ([], {'max_examples': 'MAX_EXAMPLES'}), '(max_examples=MAX_EXAMPLES)\n', (249, 276), True, 'import hypothesis as hp\n'), ((358, 390), 'pypeln.thread.from_iterable', 'pl.thread.from_iterable', (['nums_pl'], {}), '(nums_pl)\n', (381, 390), True, 'import pypeln as pl\n'), ((405, 434), 'cytoolz.partition_all', 'cz.partition_all', (['(10)', 'nums_pl'], {}), '(10, nums_pl)\n', (421, 434), True, 'import cytoolz as cz\n'), ((449, 476), 'pypeln.thread.map', 'pl.thread.map', (['sum', 'nums_pl'], {}), '(sum, nums_pl)\n', (462, 476), True, 'import pypeln as pl\n'), ((491, 521), 'pypeln.thread.to_iterable', 'pl.thread.to_iterable', (['nums_pl'], {}), '(nums_pl)\n', (512, 521), True, 'import pypeln as pl\n'), ((584, 613), 'cytoolz.partition_all', 'cz.partition_all', (['(10)', 'nums_py'], {}), '(10, nums_py)\n', (600, 613), True, 'import cytoolz as cz\n'), ((221, 234), 'hypothesis.strategies.integers', 'st.integers', ([], {}), '()\n', (232, 234), True, 'from hypothesis import strategies as st\n')]