def test_4(self, bash): got = assert_bash_exec( bash, '_muttconffiles "$HOME/muttrc" "$HOME/muttrc"', want_output=True).strip().split() assert got == ["%s/mutt/%s" % (bash.cwd, x) for x in ("muttrc", "bar/muttrc_b", "foo/muttrc_f")]
def _test_part_full(self, bash, part, full): res = assert_bash_exec( bash, '_tilde "~%s"; echo "${COMPREPLY[@]}"' % part, want_output=True, ).strip().split() assert res assert res[0] == "~%s" % full
def test_3(self, bash): """~part should complete to ~full<SPACE> if home dir does not exist.""" res = assert_bash_exec( bash, "for u in $(compgen -u); do " "eval test -d ~$u || echo $u; unset u; done", want_output=True).strip().split() part_full = find_unique_completion_pair(res) if not part_full: pytest.skip("No suitable test user found") return part, full = part_full completion = assert_complete(bash, "ls ~%s" % part) assert completion.list == ["~%s" % full] assert completion.line.endswith(" ")
def test_1(self, bash): assert_bash_exec(bash, "_expand >/dev/null")
def test_16(self, bash): """a b::| with WORDBREAKS -= : should return b::""" assert_bash_exec(bash, "add_comp_wordbreak_char :") output = self._test(bash, "(a b::)", 1, "a b::", 5, arg=":") assert output == "b::"
def test_11(self, bash): assert_bash_exec(bash, "fn() { echo ----; echo ---foo; echo '----- bar'; }") output = assert_bash_exec(bash, "_parse_usage fn") assert not output
def test_1(self, bash): assert_bash_exec(bash, "_get_comp_words_by_ref cur >/dev/null")
def test_1(self, bash): assert_bash_exec(bash, "_tilde >/dev/null")
def test_7(self, bash): assert_bash_exec(bash, "fn() { echo '[-s, --long=arg]'; }") output = assert_bash_exec(bash, "_parse_usage fn", want_output=True) assert output.split() == "--long=".split()
def test_3(self, bash): assert_bash_exec(bash, "fn() { echo 'internal-dash'; }") output = assert_bash_exec(bash, "_parse_help fn") assert not output
def test_4(self, bash): assert_bash_exec(bash, "fn() { echo 'no -leading-dashes'; }") output = assert_bash_exec(bash, "_parse_help fn") assert not output
def test_29(self, bash): """Test parsing from stdin.""" output = assert_bash_exec(bash, "echo '-f or --foo' | _parse_help -", want_output=True) assert output.split() == "--foo".split()
def test_30(self, bash): """More than two dashes should not be treated as options.""" assert_bash_exec( bash, r"fn() { printf '%s\n' $'----\n---foo\n----- bar'; }") output = assert_bash_exec(bash, "_parse_help fn") assert not output
def test_24(self, bash): assert_bash_exec(bash, "fn() { echo '-[dont]x --[dont]yy'; }") output = assert_bash_exec(bash, "_parse_help fn", want_output=True) assert output.split() == "--yy --dontyy".split()
def test_23(self, bash): assert_bash_exec(bash, "fn() { echo '--[dont-]foo'; }") output = assert_bash_exec(bash, "_parse_help fn", want_output=True) assert output.split() == "--foo --dont-foo".split()
def test_22(self, bash): assert_bash_exec(bash, "fn() { echo '--[no-]bar=quux'; }") output = assert_bash_exec(bash, "_parse_help fn", want_output=True) assert output.split() == "--bar= --no-bar=".split()
def test_1(self, bash): """Test environment non-pollution, detected at teardown.""" assert_bash_exec( bash, 'foo() { local cur prev words cword; _init_completion; }; ' 'foo; unset foo')
def test_6(self, bash): assert_bash_exec(bash, "fn() { echo ' -space dash'; }") output = assert_bash_exec(bash, "_parse_help fn", want_output=True) assert output.split() == "-space".split()
def test_3(self, bash): """Test for https://bugs.debian.org/766163""" assert_bash_exec(bash, '_tilde ~-o')
def test_9(self, bash): assert_bash_exec(bash, "fn() { echo '-one dash-inside'; }") output = assert_bash_exec(bash, "_parse_help fn", want_output=True) assert output.split() == "-one".split()
def test_3(self, bash): assert_bash_exec(bash, "fn() { echo 'foo [-f]'; }") output = assert_bash_exec(bash, "_parse_usage fn", want_output=True) assert output.split() == "-f".split()
def test_10(self, bash): """Test value not included in completion.""" assert_bash_exec(bash, "fn() { echo '--long-arg=value'; }") output = assert_bash_exec(bash, "_parse_help fn", want_output=True) assert output.split() == "--long-arg=".split()
def test_9(self, bash): assert_bash_exec(bash, "fn() { echo '[ -a ] [ -b foo ]'; }") output = assert_bash_exec(bash, "_parse_usage fn", want_output=True) assert output.split() == "-a -b".split()
def test_11(self, bash): """Test -value not seen as option.""" assert_bash_exec(bash, "fn() { echo '--long-arg=-value'; }") output = assert_bash_exec(bash, "_parse_help fn", want_output=True) assert output.split() == "--long-arg=".split()
def test_1(self, bash): assert_bash_exec(bash, "fn() { echo; }") output = assert_bash_exec(bash, "_parse_usage fn") assert not output
def test_12(self, bash): """a b:c| with WORDBREAKS += : should return c""" assert_bash_exec(bash, "add_comp_wordbreak_char :") output = self._test(bash, "(a b : c)", 3, "a b:c", 5) assert output == "c"
def test_1(self, bash): assert_bash_exec(bash, "_count_args >/dev/null")
def test_16(self, bash): assert_bash_exec(bash, "fn() { echo '-f, -F, --foo'; }") output = assert_bash_exec(bash, "_parse_help fn", want_output=True) assert output.split() == "--foo".split()
def test_12(self, bash): assert_bash_exec(bash, "fn() { echo '--long-arg=-value,--opt2=val'; }") output = assert_bash_exec(bash, "_parse_help fn", want_output=True) assert output.split() == "--long-arg=".split()
def test_14(self, bash): """a b c:| with WORDBREAKS -= : should return c:""" assert_bash_exec(bash, "add_comp_wordbreak_char :") output = self._test(bash, "(a b c :)", 3, "a b c:", 6, arg=":") assert output == "c:"
def test_15(self, bash): assert_bash_exec(bash, "fn() { echo '-T|--upload-file'; }") output = assert_bash_exec(bash, "_parse_help fn", want_output=True) assert output.split() == "--upload-file".split()
def test_13(self, bash): assert_bash_exec(bash, "fn() { echo '-m,--mirror'; }") output = assert_bash_exec(bash, "_parse_help fn", want_output=True) assert output.split() == "--mirror".split()
def test_18(self, bash): assert_bash_exec(bash, "fn() { echo '--foo=<bar>'; }") output = assert_bash_exec(bash, "_parse_help fn", want_output=True) assert output.split() == "--foo=".split()
def test_1(self, bash): assert_bash_exec(bash, "_ip_addresses")
def test_2(self, bash): """Test environment non-pollution, detected at teardown.""" assert_bash_exec( bash, 'foo() { local aa="~"; _tilde "$aa"; }; foo; unset foo')
def test_1(self, bash): assert_bash_exec(bash, "fn() { echo; }") output = assert_bash_exec(bash, "_parse_help fn") assert not output
def test_1(self, bash): assert_bash_exec(bash, "COMP_CWORD= _count_args >/dev/null")
def test_2(self, bash): assert_bash_exec(bash, "fn() { echo 'no dashes here'; }") output = assert_bash_exec(bash, "_parse_usage fn") assert not output
def test_1(self, bash, completion): hosts = assert_bash_exec(bash, "compgen -A hostname", want_output=True).split() assert all(x in completion for x in hosts) assert "lftptest" in completion # defined in lftp/.lftp/bookmarks
def test_4(self, bash): assert_bash_exec(bash, "fn() { echo 'bar [-aBcD] [-e X]'; }") output = assert_bash_exec(bash, "_parse_usage fn", want_output=True) assert output.split() == "-a -B -c -D -e".split()
def test_8(self, bash): assert_bash_exec(bash, "fn() { echo '[--long/-s] [-S/--longer]'; }") output = assert_bash_exec(bash, "_parse_usage fn", want_output=True) assert output.split() == "--long --longer".split()
def test_10(self, bash): assert_bash_exec(bash, "fn() { echo '[ -a | --aa ]'; }") output = assert_bash_exec(bash, "_parse_usage fn", want_output=True) assert output.split() == "--aa".split()
def test_12(self, bash): output = assert_bash_exec( bash, "echo '[-duh]' | _parse_usage -", want_output=True) assert output.split() == "-d -u -h".split()
def _test(self, bash, *args, **kwargs): assert_bash_exec(bash, "unset cur prev") output = self._test_unit( "_get_comp_words_by_ref %s cur prev; echo $cur,$prev", bash, *args, **kwargs) return output.strip()
def test_17(self, bash): """a b:c| with WORDBREAKS += :""" assert_bash_exec(bash, "add_comp_wordbreak_char :") output = self._test(bash, "(a b : c)", 3, "a b:c", 5) assert output == "c,:"
def test_2(self, bash): """Test environment non-pollution, detected at teardown.""" assert_bash_exec( bash, 'foo() { _expand; }; foo; unset foo')
def test_1(self, bash, completion): hosts = assert_bash_exec( bash, "compgen -A hostname", want_output=True).split() for host in hosts: assert host in completion.list assert "lftptest" in completion.list # defined in lftp/.lftp/bookmarks
def test_1(self, bash, completion): users = sorted(assert_bash_exec( bash, "compgen -A user", want_output=True).split()) assert completion.list == users
def test_1(self, bash): assert_bash_exec(bash, "_get_cword >/dev/null")