def assert_has_attr(obj, attribute, msg_fmt="{msg}"):
    """Fail is an object does not have an attribute.

    >>> assert_has_attr([], "index")
    >>> assert_has_attr([], "i_do_not_have_this")
    Traceback (most recent call last):
        ...
    AssertionError: [] does not have attribute 'i_do_not_have_this'

    The following msg_fmt arguments are supported:
    * msg - the default error message
    * obj - object to test
    * attribute - name of the attribute to check
    """

    if not hasattr(obj, attribute):
        msg = "{!r} does not have attribute '{}'".format(obj, attribute)
        fail(msg_fmt.format(msg=msg, obj=obj, attribute=attribute))
Fail is an object does not have an attribute.

    >>> assert_has_attr([], "index")
    >>> assert_has_attr([], "i_do_not_have_this")
    Traceback (most recent call last):
        ...
    AssertionError: [] does not have attribute 'i_do_not_have_this'

    The following msg_fmt arguments are supported:
    * msg - the default error message
    * obj - object to test
    * attribute - name of the attribute to check