def and_return()

in doubles/allowance.py [0:0]


    def and_return(self, *return_values):
        """Set a return value for an allowance

        Causes the double to return the provided values in order.  If multiple
        values are provided, they are returned one at a time in sequence as the double is called.
        If the double is called more times than there are return values, it should continue to
        return the last value in the list.


        :param object return_values: The values the double will return when called,
        """

        if not return_values:
            raise TypeError('and_return() expected at least 1 return value')

        return_values = list(return_values)
        final_value = return_values.pop()

        self.and_return_result_of(
            lambda: return_values.pop(0) if return_values else final_value
        )
        return self