-
Notifications
You must be signed in to change notification settings - Fork 379
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Convert some more test cases to pytest+pexpect
- Loading branch information
Showing
19 changed files
with
261 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,13 @@ | ||
EXTRA_DIST = \ | ||
test_count_args.py \ | ||
test_expand.py \ | ||
test_expand_tilde_by_ref.py \ | ||
test_filedir.py \ | ||
test_get_comp_words_by_ref.py \ | ||
test_get_cword.py \ | ||
test_init_completion.py \ | ||
test_ip_addresses.py \ | ||
test_parse_help.py \ | ||
test_tilde.py \ | ||
|
||
all: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import pytest | ||
|
||
from conftest import assert_bash_exec | ||
|
||
|
||
@pytest.mark.bashcomp(cmd=None, ignore_env=r"^\+args=") | ||
class TestUnitCountArgs(object): | ||
|
||
def test_1(self, bash): | ||
assert_bash_exec(bash, "_count_args >/dev/null") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import pytest | ||
|
||
from conftest import assert_bash_exec | ||
|
||
|
||
@pytest.mark.bashcomp(cmd=None) | ||
class TestUnitExpand(object): | ||
|
||
def test_1(self, bash): | ||
assert_bash_exec(bash, "_expand >/dev/null") | ||
|
||
def test_2(self, bash): | ||
"""Test environment non-pollution, detected at teardown.""" | ||
assert_bash_exec( | ||
bash, 'foo() { _expand; }; foo; unset foo') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import pytest | ||
|
||
from conftest import assert_bash_exec | ||
|
||
|
||
@pytest.mark.bashcomp(cmd=None) | ||
class TestUnitExpandTildeByRef(object): | ||
|
||
def test_1(self, bash): | ||
assert_bash_exec(bash, "__expand_tilde_by_ref >/dev/null") | ||
|
||
def test_2(self, bash): | ||
"""Test environment non-pollution, detected at teardown.""" | ||
assert_bash_exec( | ||
bash, | ||
'_x() { local aa="~"; __expand_tilde_by_ref aa; }; _x; unset _x') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import pytest | ||
|
||
from conftest import assert_bash_exec | ||
|
||
|
||
@pytest.mark.bashcomp(cmd=None, ignore_env=r"^\+COMPREPLY=") | ||
class TestUnitFiledir(object): | ||
|
||
def test_1(self, bash): | ||
assert_bash_exec(bash, "_filedir >/dev/null") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import pytest | ||
|
||
from conftest import assert_bash_exec | ||
|
||
|
||
@pytest.mark.bashcomp(cmd=None, ignore_env=r"^\+cur=") | ||
class TestUnitGetCompWordsByRef(object): | ||
|
||
def test_1(self, bash): | ||
assert_bash_exec(bash, "_get_comp_words_by_ref cur >/dev/null") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import pytest | ||
|
||
from conftest import assert_bash_exec | ||
|
||
|
||
@pytest.mark.bashcomp(cmd=None) | ||
class TestUnitGetCword(object): | ||
|
||
def test_1(self, bash): | ||
assert_bash_exec(bash, "_get_cword >/dev/null") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import pytest | ||
|
||
from conftest import assert_bash_exec | ||
|
||
|
||
@pytest.mark.bashcomp(cmd=None, ignore_env=r"^\+COMPREPLY=") | ||
class TestUnitInitCompletion(object): | ||
|
||
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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import pytest | ||
|
||
from conftest import assert_bash_exec | ||
|
||
|
||
@pytest.mark.bashcomp(cmd=None, ignore_env=r"^\+COMPREPLY=") | ||
class TestUnitIpAddresses(object): | ||
|
||
def test_1(self, bash): | ||
assert_bash_exec(bash, "_ip_addresses") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
# Based on work by Stephen Gildea, October 2010. | ||
|
||
import pytest | ||
|
||
from conftest import assert_bash_exec | ||
|
||
|
||
@pytest.mark.bashcomp(cmd=None, ignore_env=r"^\+declare -f fn$") | ||
class TestUnitParseHelp(object): | ||
|
||
def test_1(self, bash): | ||
assert_bash_exec(bash, "fn() { echo; }") | ||
output = assert_bash_exec(bash, "_parse_help fn") | ||
assert not output | ||
|
||
def test_2(self, bash): | ||
assert_bash_exec(bash, "fn() { echo 'no dashes here'; }") | ||
output = assert_bash_exec(bash, "_parse_help fn") | ||
assert not output | ||
|
||
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_5(self, bash): | ||
assert_bash_exec(bash, "fn() { echo '-one dash'; }") | ||
output = assert_bash_exec(bash, "_parse_help fn", want_output=True) | ||
assert output.split() == "-one".split() | ||
|
||
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_7(self, bash): | ||
assert_bash_exec(bash, "fn() { echo '-one -two dashes'; }") | ||
output = assert_bash_exec(bash, "_parse_help fn", want_output=True) | ||
assert output.split() == "-one".split() | ||
|
||
def test_8(self, bash): | ||
assert_bash_exec(bash, "fn() { echo '-one,-t dashes'; }") | ||
output = assert_bash_exec(bash, "_parse_help fn", want_output=True) | ||
assert output.split() == "-one".split() | ||
|
||
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_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_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_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_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_14(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_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_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_17(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_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_19(self, bash): | ||
assert_bash_exec(bash, "fn() { echo '--foo={bar,quux}'; }") | ||
output = assert_bash_exec(bash, "_parse_help fn", want_output=True) | ||
assert output.split() == "--foo=".split() | ||
|
||
def test_20(self, bash): | ||
assert_bash_exec(bash, "fn() { echo '--[no]foo'; }") | ||
output = assert_bash_exec(bash, "_parse_help fn", want_output=True) | ||
assert output.split() == "--foo --nofoo".split() | ||
|
||
def test_21(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_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_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_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_25(self, bash): | ||
assert_bash_exec(bash, "fn() { echo '-f FOO, --foo=FOO'; }") | ||
output = assert_bash_exec(bash, "_parse_help fn", want_output=True) | ||
assert output.split() == "--foo=".split() | ||
|
||
def test_26(self, bash): | ||
assert_bash_exec(bash, "fn() { echo '-f [FOO], --foo[=FOO]'; }") | ||
output = assert_bash_exec(bash, "_parse_help fn", want_output=True) | ||
assert output.split() == "--foo".split() | ||
|
||
def test_27(self, bash): | ||
assert_bash_exec(bash, "fn() { echo '--foo.'; }") | ||
output = assert_bash_exec(bash, "_parse_help fn", want_output=True) | ||
assert output.split() == "--foo".split() | ||
|
||
def test_28(self, bash): | ||
assert_bash_exec(bash, "fn() { echo '-f or --foo'; }") | ||
output = assert_bash_exec(bash, "_parse_help fn", want_output=True) | ||
assert output.split() == "--foo".split() | ||
|
||
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.