Ejemplo n.º 1
0
 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")]
Ejemplo n.º 2
0
 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
Ejemplo n.º 3
0
 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")
Ejemplo n.º 5
0
 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")
Ejemplo n.º 8
0
 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()
Ejemplo n.º 10
0
 def test_3(self, bash):
     assert_bash_exec(bash, "fn() { echo 'internal-dash'; }")
     output = assert_bash_exec(bash, "_parse_help fn")
     assert not output
Ejemplo n.º 11
0
 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
Ejemplo n.º 12
0
 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()
Ejemplo n.º 13
0
 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
Ejemplo n.º 14
0
 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()
Ejemplo n.º 15
0
 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()
Ejemplo n.º 16
0
 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')
Ejemplo n.º 18
0
 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()
Ejemplo n.º 19
0
 def test_3(self, bash):
     """Test for https://bugs.debian.org/766163"""
     assert_bash_exec(bash, '_tilde ~-o')
Ejemplo n.º 20
0
 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()
Ejemplo n.º 22
0
 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()
Ejemplo n.º 24
0
 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
Ejemplo n.º 26
0
 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()
Ejemplo n.º 29
0
 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()
Ejemplo n.º 30
0
 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()
Ejemplo n.º 32
0
 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()
Ejemplo n.º 34
0
 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_1(self, bash):
     assert_bash_exec(bash, "_ip_addresses")
Ejemplo n.º 36
0
 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()
Ejemplo n.º 37
0
 def test_2(self, bash):
     """Test environment non-pollution, detected at teardown."""
     assert_bash_exec(
         bash,
         'foo() { local aa="~"; _tilde "$aa"; }; foo; unset foo')
Ejemplo n.º 38
0
 def test_1(self, bash):
     assert_bash_exec(bash, "fn() { echo; }")
     output = assert_bash_exec(bash, "_parse_help fn")
     assert not output
Ejemplo n.º 39
0
 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, "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
Ejemplo n.º 42
0
 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()
Ejemplo n.º 44
0
 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_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()
Ejemplo n.º 46
0
 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):
     assert_bash_exec(bash, "fn() { echo '[ -a | --aa ]'; }")
     output = assert_bash_exec(bash, "_parse_usage fn", want_output=True)
     assert output.split() == "--aa".split()
Ejemplo n.º 48
0
 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_12(self, bash):
     output = assert_bash_exec(
         bash, "echo '[-duh]' | _parse_usage -", want_output=True)
     assert output.split() == "-d -u -h".split()
Ejemplo n.º 50
0
 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(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()
Ejemplo n.º 52
0
 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_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,:"
Ejemplo n.º 54
0
 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()
Ejemplo n.º 55
0
 def test_2(self, bash):
     """Test environment non-pollution, detected at teardown."""
     assert_bash_exec(
         bash, 'foo() { _expand; }; foo; unset foo')
Ejemplo n.º 56
0
 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()
Ejemplo n.º 57
0
 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_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()
Ejemplo n.º 59
0
 def test_1(self, bash, completion):
     users = sorted(assert_bash_exec(
         bash, "compgen -A user", want_output=True).split())
     assert completion.list == users
Ejemplo n.º 60
0
 def test_1(self, bash):
     assert_bash_exec(bash, "_get_cword >/dev/null")