def _validate_file_ownership(owner, group, file_name, optional=False):
    """
    Validate that a specified file is owned by `owner:group`.

    :param owner: Name of the owner
    :type owner: str
    :param group: Name of the group
    :type group: str
    :param file_name: Path to the file to verify
    :type file_name: str
    :param optional: Is this file optional,
                     ie: Should this test fail when it's missing
    :type optional: bool
    """
    try:
        ownership = _stat(file_name)
    except subprocess.CalledProcessError as e:
        print("Error reading file: {}".format(e))
        if not optional:
            assert False, "Specified file does not exist: {}".format(file_name)
    assert owner == ownership.owner, \
        "{} has an incorrect owner: {} should be {}".format(
            file_name, ownership.owner, owner)
    assert group == ownership.group, \
        "{} has an incorrect group: {} should be {}".format(
            file_name, ownership.group, group)
    print("Validate ownership of {}: PASS".format(file_name))
def _validate_file_ownership ( owner , group , file_name , optional = False ) : try : ownership = _stat ( file_name ) except subprocess . CalledProcessError as e : print ( "Error reading file: {}" . format ( e ) ) if not optional : assert False , "Specified file does not exist: {}" . format ( file_name ) assert owner == ownership . owner , "{} has an incorrect owner: {} should be {}" . format ( file_name , ownership . owner , owner ) assert group == ownership . group , "{} has an incorrect group: {} should be {}" . format ( file_name , ownership . group , group ) print ( "Validate ownership of {}: PASS" . format ( file_name ) )
Validate that a specified file is owned by `owner:group`.

    :param owner: Name of the owner
    :type owner: str
    :param group: Name of the group
    :type group: str
    :param file_name: Path to the file to verify
    :type file_name: str
    :param optional: Is this file optional,
                     ie: Should this test fail when it's missing
    :type optional: bool