def test_lazylist_multi_map_iterable_and_callable(): class double_func(collections.Iterable): def __call__(self, x, **kwargs): return x * 2 def __iter__(self): yield 1 f = double_func() two_func = lambda: 2 ll = LazyList([two_func]) with raises(ValueError): ll.map(f)
def test_lazylist_multi_map_iterable_and_callable(): class double_func(collections_abc.Iterable): def __call__(self, x, **kwargs): return x * 2 def __iter__(self): yield 1 f = double_func() two_func = lambda: 2 ll = LazyList([two_func]) with raises(ValueError): ll.map(f)
def test_lazylist_multi_map_iterable_and_callable(): class double_func(collections.Iterable): def __call__(self, x, **kwargs): return x * 2 def __iter__(self): yield 1 f = double_func() two_func = lambda: 2 ll = LazyList([two_func]) ll.map(f) assert 1
def test_lazylist_map(): two_func = lambda: 2 double_func = lambda x: x * 2 ll = LazyList([two_func]) ll_mapped = ll.map(double_func) assert id(ll) != id(ll_mapped) assert ll_mapped[0] == 4
def test_lazylist_map_no_call(): mock_func = Mock() double_func = lambda x: x * 2 ll = LazyList([mock_func]) ll_mapped = ll.map(double_func) assert id(ll) != id(ll_mapped) mock_func.assert_not_called()
def test_lazylist_multi_map(): two_func = lambda: 2 double_func = [lambda x: x * 2] * 2 ll = LazyList([two_func] * 2) ll_mapped = ll.map(double_func) assert len(ll_mapped) == 2 assert id(ll) != id(ll_mapped) assert all(x == 4 for x in ll_mapped)
def test_lazylist_multi_map_unequal_lengths(): two_func = lambda: 2 double_func = [lambda x: x * 2] * 2 ll = LazyList([two_func]) with raises(ValueError): ll.map(double_func)
def test_lazylist_multi_map_unequal_lengths(): two_func = lambda: 2 double_func = [lambda x: x * 2] * 2 ll = LazyList([two_func]) ll.map(double_func)