def assert_empty(iterable, max_elements_to_print=None, message=None):
    """
    Assert that an iterable contains no values.

    Args:
        iterable - any iterable object
        max_elements_to_print - int or None, maximum number of elements from
            iterable to include in the error message. by default, includes all
            elements from iterables with a len(), and 10 elements otherwise.
            if max_elements_to_print is 0, no sample is printed.
        message - str or None, custom message to print if the iterable yields.
            a sample is appended to the end unless max_elements_to_print is 0.
    """
    # Determine whether or not we can print all of iterable, which could be
    # an infinite (or very slow) generator.
    if max_elements_to_print is None:
        try:
            max_elements_to_print = len(iterable)
        except TypeError:
            max_elements_to_print = 10

    # Build the message *before* touching iterable since that might modify it.
    message = message or "iterable {0} was unexpectedly non-empty.".format(iterable)

    # Get the first max_elements_to_print + 1 items from iterable, or just
    # the first item if max_elements_to_print is 0.  Trying to get an
    # extra item by adding 1 to max_elements_to_print lets us tell whether
    # we got everything in iterator, regardless of if it has len() defined.
    if max_elements_to_print == 0:
        sample = list(islice(iterable, 0, 1))
    else:
        sample_plus_extra = list(islice(iterable, 0, max_elements_to_print + 1))
        sample_is_whole_iterable = len(sample_plus_extra) <= max_elements_to_print
        sample = sample_plus_extra[:max_elements_to_print]

        if sample_is_whole_iterable:
            message += ' elements: %s' % sample
        else:
            message += ' first %s elements: %s' % (len(sample), sample)

    assert len(sample) == 0, message
dataset/ETHPy150Open Yelp/Testify/testify/assertions.py/assert_empty/original