Example #1
0
async def test_count_invalid_start():
    """Check that count raises TypeError when start is not a number."""
    with pytest.raises(TypeError):

        await aitertools.anext(aitertools.count('a'))
Example #2
0
async def test_count_negative_step():
    """Check that count can handle negative step values."""
    counter = aitertools.count(0, -1)
    assert (await aitertools.anext(counter)) == 0
    assert (await aitertools.anext(counter)) == -1
Example #3
0
async def test_count_too_many_args():
    """Check that count raises TypeError when too many args."""
    with pytest.raises(TypeError):

        await aitertools.anext(aitertools.count(1, 2, 3))
Example #4
0
async def test_count_custom_step():
    """Check that a custom step can be given."""
    counter = aitertools.count(0, 2)
    assert (await aitertools.anext(counter)) == 0
    assert (await aitertools.anext(counter)) == 2
Example #5
0
async def test_count_steps_one():
    """Check that the default count step is one."""
    counter = aitertools.count()
    assert (await aitertools.anext(counter)) == 0
    assert (await aitertools.anext(counter)) == 1
Example #6
0
async def test_count_negative_start():
    """Check that count can start with negative values."""
    assert (await aitertools.anext(aitertools.count(-1))) == -1
Example #7
0
async def test_count_custom_start():
    """Check that count can be give a custom start."""
    assert (await aitertools.anext(aitertools.count(3))) == 3
Example #8
0
async def test_count_starts_at_zero():
    """Check that default counts start as zero."""
    assert (await aitertools.anext(aitertools.count())) == 0