コード例 #1
0
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)
コード例 #2
0
ファイル: test_lazylist.py プロジェクト: tzirakis/menpo
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)
コード例 #3
0
ファイル: lazylist_test.py プロジェクト: zhixinshu/menpo
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
コード例 #4
0
ファイル: test_lazylist.py プロジェクト: tzirakis/menpo
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
コード例 #5
0
ファイル: test_lazylist.py プロジェクト: tzirakis/menpo
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()
コード例 #6
0
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
コード例 #7
0
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()
コード例 #8
0
ファイル: test_lazylist.py プロジェクト: tzirakis/menpo
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)
コード例 #9
0
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)
コード例 #10
0
ファイル: test_lazylist.py プロジェクト: tzirakis/menpo
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)
コード例 #11
0
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)
コード例 #12
0
ファイル: lazylist_test.py プロジェクト: zhixinshu/menpo
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)