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