示例#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'))
示例#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
示例#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))
示例#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
示例#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
示例#6
0
async def test_count_negative_start():
    """Check that count can start with negative values."""
    assert (await aitertools.anext(aitertools.count(-1))) == -1
示例#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
示例#8
0
async def test_count_starts_at_zero():
    """Check that default counts start as zero."""
    assert (await aitertools.anext(aitertools.count())) == 0