def print_failure(filename, failure, colored=False, verbose=False):
    """
    Pretty prints a failure

    :param filename: str, path to file tested
    :param failure: Failure
    :param colored: bool, prints with ansi colors according to failure severity
    """
    def color_string(message, severity):
        RED = '31m'
        YELLOW = '33m'
        BLUE = '34m'
        WHITE = '37m'
        RESET = '0m'
        color_map = {
            'ERROR': RED,
            'WARNING': YELLOW,
            'INFO': BLUE,
        }
        return f'\033[{color_map.get(severity, WHITE)}{message}\033[{RESET}'
    message = f'[{failure.role}] {filename}:{failure.line}: {failure.element}: {failure.message}'
    if verbose:
        message += f'\n    location: {failure.location}\n    test: {failure.test}'
    if colored:
        message = color_string(message, failure.role)
    # print(message)
    return message