Beispiel #1
0
def test_filter_collect_sequential():
    @asyncio.coroutine
    def coro(num):
        yield from asyncio.sleep(0.1)
        return (yield from even(num))

    init = time.time()
    task = filter(coro, [1, 2, 3, 4, 5, 6], limit=1)
    assert run_in_loop(task) == [2, 4, 6]
    assert time.time() - init >= 0.5
Beispiel #2
0
def test_filter_invalid_coro():
    with pytest.raises(TypeError):
        run_in_loop(filter(None))
Beispiel #3
0
def test_filter_invalid_input():
    with pytest.raises(TypeError):
        run_in_loop(filter(even, None))
Beispiel #4
0
def test_filter_empty():
    assert run_in_loop(filter(even, [])) == []
Beispiel #5
0
def test_filter():
    task = filter(even, [1, 2, 3, 4, 5, 6])
    assert run_in_loop(task) == [2, 4, 6]
Beispiel #6
0
async def task(numbers):
    return await (numbers
                   | paco.filter(filterer)
                   | paco.map(mapper)
                   | paco.dropwhile(drop)
                   | paco.reduce(reducer, initializer=0))  # noqa
Beispiel #7
0
 def task(numbers):
     return (yield from (numbers
                         | paco.filter(filterer)
                         | paco.map(mapper)
                         | paco.dropwhile(drop)
                         | paco.reduce(reducer, initializer=0)))