# Path: apps/service/async_helpers.py
# def timing_generator(interval, amount, initial=None):
#     """ Generator to make generic repeating timer
# 
#     Returns (bool, value) tuples, where:
#             bool: if true, then this is last iteration of sequence
#             value: ether interval or initial value
# 
#     :param interval: number to be returned each iteration
#     :param amount:  number of iterations
#     :param initial: if specified, this value will be used on 1st iteration
#     :return: (bool, int)
#     """
#     assert amount > 0
# 
#     if initial is not None:
#         amount -= 1
#         yield amount == 0, initial
# 
#     for index, value in enumerate(repeat(interval, amount), start=1):
#         yield index == amount, value


from unittest import TestCase
from apps.service.async_helpers import timing_generator
# -*- coding: utf-8 -*-



class TimingTests(TestCase):
    def test_normal(self):
        exp = [(False, 2), (False, 2), (False, 2), (True, 2)]

# Path: apps/service/async_helpers.py
# def timing_generator(interval, amount, initial=None):
#     """ Generator to make generic repeating timer
# 
#     Returns (bool, value) tuples, where:
#             bool: if true, then this is last iteration of sequence
#             value: ether interval or initial value
# 
#     :param interval: number to be returned each iteration
#     :param amount:  number of iterations
#     :param initial: if specified, this value will be used on 1st iteration
#     :return: (bool, int)
#     """
#     assert amount > 0
# 
#     if initial is not None:
#         amount -= 1
#         yield amount == 0, initial
# 
#     for index, value in enumerate(repeat(interval, amount), start=1):
#         yield index == amount, value


# Path: tests/test_services.py
from unittest import TestCase
from apps.service.async_helpers import timing_generator

# -*- coding: utf-8 -*-



class TimingTests(TestCase):
    def test_normal(self):
        exp = [(False, 2), (False, 2), (False, 2), (True, 2)]

        res = list(timing_generator(2, 4))