async def test_compress_invalid_args(): """Check that compress raises TypeError when args aren't iterable.""" with pytest.raises(TypeError): await aitertools.anext(aitertools.compress(None, range(10))) with pytest.raises(TypeError): await aitertools.anext(aitertools.compress(range(10), None))
async def test_compress_too_many_args(): """Check that compress raises TypeError when too many args.""" with pytest.raises(TypeError): await aitertools.anext(aitertools.compress([], [], []))
async def test_compress_all_true_selectors(): """Check that compress returns all values when selectors are True.""" assert (await aitertools.alist( aitertools.compress('ABCDEF', range(1, 10)) )) == list('ABCDEF')
async def test_compress_all_false_selectors(): """Check that compress is empty when all selectors are False.""" assert (await aitertools.alist( aitertools.compress('ABCDEF', aitertools.repeat(0)) )) == []
async def test_compress_removes_when_selector_false(): """Check that compress only emits values with True selectors.""" assert (await aitertools.alist( aitertools.compress('ABCDEF', [1, 0, 1, 0, 1, 1]) )) == list('ACEF')