def METHOD_NAME(
    self, bash, hosts, avahi_hosts, prefix, colon_flag, hostfile
):
    expected = (
        "%s%s%s" % (prefix, x, ":" if colon_flag else "")
        for x in chain(
            hosts if hostfile else avahi_hosts,
            # fixtures/_known_hosts_real/config
            "gee hus jar #not-a-comment".split(),
            # fixtures/_known_hosts_real/known_hosts
            (
                "doo",
                "ike",
                "jub",
                "10.0.0.1",
                "kyl",
                "100.0.0.2",
                "10.10.0.3",
                "blah",
                "fd00:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:5555",
                "fe80::123:0xff:dead:beef%eth0",
                "1111:2222:3333:4444:5555:6666:xxxx:abab",
                "11xx:2222:3333:4444:5555:6666:xxxx:abab",
                "::42",
            ),
        )
    )
    assert_bash_exec(
        bash,
        "unset -v BASH_COMPLETION_KNOWN_HOSTS_WITH_HOSTFILE"
        if hostfile
        else "BASH_COMPLETION_KNOWN_HOSTS_WITH_HOSTFILE=",
    )
    output = assert_bash_exec(
        bash,
        "_known_hosts_real -a%sF _known_hosts_real/config '%s'; "
        r'printf "%%s\n" "${COMPREPLY[@]}"; unset -v COMPREPLY'
        % (colon_flag, prefix),
        want_output=True,
    )
    assert sorted(set(output.split())) == sorted(expected)