async def test_cycle_repeats_values(): """Check if the cycle repeats values on a loop.""" cycler = aitertools.cycle('abc') assert (await aitertools.anext(cycler)) == 'a' assert (await aitertools.anext(cycler)) == 'b' assert (await aitertools.anext(cycler)) == 'c' assert (await aitertools.anext(cycler)) == 'a' assert (await aitertools.anext(cycler)) == 'b' assert (await aitertools.anext(cycler)) == 'c'
async def test_cycle_non_iterable(): """Check if cycle raises TypeError when given a non-iterable value.""" with pytest.raises(TypeError): await aitertools.anext(aitertools.cycle(5))
async def test_cycle_too_few_args(): """Check if cycle raises TypeError when too few args.""" with pytest.raises(TypeError): await aitertools.anext(aitertools.cycle())
async def test_cycle_is_empty_if_iterable_is_empty(): """Check if cycle emits no values when given an empty iterable.""" assert (await aitertools.alist( aitertools.cycle('') )) == []