def ask(question, default_answer=False, default_answer_str="no"):
    """
    Ask for user input.

    This asks a yes/no question with a preset default.
    You can bypass the user-input and fetch the default answer, if
    you set

    Args:
        question: The question to ask on stdout.
        default_answer: The default value to return.
        default_answer_str:
            The default answer string that we present to the user.

    Tests:
        >>> os.putenv("TEST", "yes"); ask("Test?", default_answer=True)
        True
        >>> os.putenv("TEST", "yes"); ask("Test?", default_answer=False)
        False
    """
    response = default_answer

    def should_ignore_tty():
        """
        Check, if we want to ignore an opened tty result.
        """
        ret_to_bool = {"yes": True, "no": False, "true": True, "false": False}
        envs = [os.getenv("CI", default="no"), os.getenv("TEST", default="no")]
        vals = [ret_to_bool[val] for val in envs if val in ret_to_bool]
        return any(vals)

    ignore_stdin_istty = should_ignore_tty()
    has_tty = sys.stdin.isatty() and not ignore_stdin_istty
    if has_tty:
        response = query_yes_no(question, default_answer_str)
    else:
        LOG.debug("NoTTY: %s -> %s", question, response)

    return response
Ask for user input.

    This asks a yes/no question with a preset default.
    You can bypass the user-input and fetch the default answer, if
    you set

    Args:
        question: The question to ask on stdout.
        default_answer: The default value to return.
        default_answer_str:
            The default answer string that we present to the user.

    Tests:
        >>> os.putenv("TEST", "yes"); ask("Test?", default_answer=True)
        True
        >>> os.putenv("TEST", "yes"); ask("Test?", default_answer=False)
        False