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, 4, 10, 19), 'typing.TypeVar', 'tp.TypeVar', ({(10, 15, 10, 18): '"""T"""'}, {}), "('T')", True, 'import typing as tp\n'), ((14, 1, 14, 39), 'hypothesis.settings', 'hp.settings', (), '', True, 'import hypothesis as hp\n'), ((18, 14, 18, 46), 'pypeln.thread.from_iterable', 'pl.thread.from_iterable', ({(18, 38, 18, 45): 'nums_pl'}, {}), '(nums_pl)', True, 'import pypeln as pl\n'), ((19, 14, 19, 43), 'cytoolz.partition_all', 'cz.partition_all', ({(19, 31, 19, 33): '10', (19, 35, 19, 42): 'nums_pl'}, {}), '(10, nums_pl)', True, 'import cytoolz as cz\n'), ((20, 14, 20, 41), 'pypeln.thread.map', 'pl.thread.map', ({(20, 28, 20, 31): 'sum', (20, 33, 20, 40): 'nums_pl'}, {}), '(sum, nums_pl)', True, 'import pypeln as pl\n'), ((21, 14, 21, 44), 'pypeln.thread.to_iterable', 'pl.thread.to_iterable', ({(21, 36, 21, 43): 'nums_pl'}, {}), '(nums_pl)', True, 'import pypeln as pl\n'), ((25, 14, 25, 43), 'cytoolz.partition_all', 'cz.partition_all', ({(25, 31, 25, 33): '10', (25, 35, 25, 42): 'nums_py'}, {}), '(10, nums_py)', True, 'import cytoolz as cz\n'), ((13, 24, 13, 37), 'hypothesis.strategies.integers', 'st.integers', ({}, {}), '()', True, 'from hypothesis import strategies as st\n')]