Example #1
0
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))
    )) == []
Example #2
0
async def test_repeat_too_many_args():
    """Check that repeat raises TypeError when too many args."""
    with pytest.raises(TypeError):

        await aitertools.anext(aitertools.repeat('a', 3, 4))
Example #3
0
async def test_repeat_invalid_args():
    """Check that repeat raises TypeError when times is non-numeric."""
    with pytest.raises(TypeError):

        await aitertools.anext(aitertools.repeat(None, 'a'))
Example #4
0
async def test_repeat_too_few_args():
    """Check that repeat raises TypeError when too few args."""
    with pytest.raises(TypeError):

        await aitertools.anext(aitertools.repeat())
Example #5
0
async def test_repeat_empty_if_negative_times():
    """Check that repeat is empty when given negative times."""
    assert (await aitertools.alist(
        aitertools.repeat('a', -1)
    )) == []
Example #6
0
async def test_repeat_empty_if_zero_times():
    """Check that repeat is empty when given zero times."""
    assert (await aitertools.alist(
        aitertools.repeat('a', 0)
    )) == []
Example #7
0
async def test_reapeat_can_limit_repititions():
    """Check that repeat limits to a given number."""
    assert (await aitertools.alist(
        aitertools.repeat('a', 3)
    )) == ['a', 'a', 'a']
Example #8
0
async def test_repeat_repeats_values():
    """Check if a value is emitted multiple times."""
    repeater = aitertools.repeat('a')
    assert (await aitertools.anext(repeater)) == 'a'
    assert (await aitertools.anext(repeater)) == 'a'
    assert (await aitertools.anext(repeater)) == 'a'