Skip to content

Commit

Permalink
test/_get_comp_words_by_ref: convert remaining test cases to pytest+p…
Browse files Browse the repository at this point in the history
…expect
  • Loading branch information
scop committed May 9, 2020
1 parent ea0236e commit 322420d
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 92 deletions.
91 changes: 90 additions & 1 deletion test/t/unit/test_unit_get_comp_words_by_ref.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@


@pytest.mark.bashcomp(
cmd=None, ignore_env=r"^(\+(cur|prev)|[+-]COMP_(WORDS|CWORD|LINE|POINT))="
cmd=None,
ignore_env=r"^(\+(words|cword|cur|prev)|[+-]COMP_(WORDS|CWORD|LINE|POINT))=",
)
class TestUnitGetCompWordsByRef(TestUnitBase):
def _test(self, bash, *args, **kwargs):
Expand Down Expand Up @@ -165,3 +166,91 @@ def test_29(self, bash):
"""a 'b&c|"""
output = self._test(bash, '(a "\'b&c")', 1, "a 'b&c", 6)
assert output == "'b&c,a"

def test_30(self, bash):
"""a b| to all vars"""
assert_bash_exec(bash, "unset words cword cur prev")
output = self._test_unit(
"_get_comp_words_by_ref words cword cur prev%s; "
'echo "${words[@]}",$cword,$cur,$prev',
bash,
"(a b)",
1,
"a b",
3,
)
assert output == "a b,1,b,a"

def test_31(self, bash):
"""a b| to alternate vars"""
assert_bash_exec(bash, "unset words2 cword2 cur2 prev2")
output = self._test_unit(
"_get_comp_words_by_ref -w words2 -i cword2 -c cur2 -p prev2%s; "
'echo $cur2,$prev2,"${words2[@]}",$cword2',
bash,
"(a b)",
1,
"a b",
3,
)
assert output == "b,a,a b,1"
assert_bash_exec(bash, "unset words2 cword2 cur2 prev2")

def test_32(self, bash):
"""a b : c| with wordbreaks -= :"""
assert_bash_exec(bash, "unset words")
output = self._test_unit(
'_get_comp_words_by_ref -n : words%s; echo "${words[@]}"',
bash,
"(a b : c)",
3,
"a b : c",
7,
)
assert output == "a b : c"

def test_33(self, bash):
"""a b: c| with wordbreaks -= :"""
assert_bash_exec(bash, "unset words")
output = self._test_unit(
'_get_comp_words_by_ref -n : words%s; echo "${words[@]}"',
bash,
"(a b : c)",
3,
"a b: c",
6,
)
assert output == "a b: c"

def test_34(self, bash):
"""a b :c| with wordbreaks -= :"""
assert_bash_exec(bash, "unset words")
output = self._test_unit(
'_get_comp_words_by_ref -n : words%s; echo "${words[@]}"',
bash,
"(a b : c)",
3,
"a b :c",
6,
)
assert output == "a b :c"

def test_35(self, bash):
r"""a b\ :c| with wordbreaks -= :"""
assert_bash_exec(bash, "unset words")
output = self._test_unit(
'_get_comp_words_by_ref -n : words%s; echo "${words[@]}"',
bash,
"(a 'b ' : c)",
3,
r"a b\ :c",
7,
)
assert output == "a b :c"

def test_unknown_arg_error(self, bash):
with pytest.raises(AssertionError) as ex:
_ = assert_bash_exec(
bash, "_get_comp_words_by_ref dummy", want_output=True
)
ex.match("dummy.* unknown argument")
91 changes: 0 additions & 91 deletions test/unit/_get_comp_words_by_ref.exp

This file was deleted.

0 comments on commit 322420d

Please sign in to comment.