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

[(10, 'typing.TypeVar', 'tp.TypeVar', True, 'import typing as tp\n'), (14, 'hypothesis.settings', 'hp.settings', True, 'import hypothesis as hp\n'), (18, 'pypeln.thread.from_iterable', 'pl.thread.from_iterable', True, 'import pypeln as pl\n'), (19, 'cytoolz.partition_all', 'cz.partition_all', True, 'import cytoolz as cz\n'), (20, 'pypeln.thread.map', 'pl.thread.map', True, 'import pypeln as pl\n'), (21, 'pypeln.thread.to_iterable', 'pl.thread.to_iterable', True, 'import pypeln as pl\n'), (25, 'cytoolz.partition_all', 'cz.partition_all', True, 'import cytoolz as cz\n'), (13, 'hypothesis.strategies.integers', 'st.integers', True, 'from hypothesis import strategies as st\n')]