diff --git a/test/lib/completions/finger.exp b/test/lib/completions/finger.exp index fa9f5b6b28e..c055f354191 100644 --- a/test/lib/completions/finger.exp +++ b/test/lib/completions/finger.exp @@ -14,13 +14,6 @@ setup sync_after_int -set test "Tab should complete partial username" -assert_complete_partial [exec bash -c "compgen -A user -S @"] "finger" "" $test -nospace - - -sync_after_int - - set test "Tab should complete partial hostname" # Build string list of hostnames, starting with the character of the first # host, unless host starts with a COMP_WORDBREAKS character, e.g. a colon (:). diff --git a/test/lib/library.exp b/test/lib/library.exp index c984cbb78eb..c90c927cf8d 100644 --- a/test/lib/library.exp +++ b/test/lib/library.exp @@ -378,37 +378,6 @@ proc assert_complete_dir {expected cmd dir {test ""} {args {}}} { -# Make sure a partial argument is completed. -# A completion is tried with `$partial', or if this is empty, the first -# character of the first item of `$expected'. Only the items from $expected, -# starting with this character are then expected as completions. -# @param list $expected List of all completions. -# @param string $cmd Command given to generate items -# @param string $partial Word to complete -# @param string $test Test title -# @param list $args See: assert_complete() -proc assert_complete_partial {expected cmd {partial ""} {test ""} {args {}}} { - if {$test == ""} {set test "$cmd should complete partial argument"} - if {[llength $expected] == 0} { - unresolved "$test" - } else { - set pick {} - # Make sure expected items are unique - set expected [lsort -unique $expected] - foreach item $expected { - if {$partial == ""} {set partial [string range $item 0 0]} - # Only append item if starting with $partial - if {[string range $item 0 [expr [string length $partial] - 1]] == "$partial"} { - lappend pick $item - } - } - # NOTE: The `eval' is necessary to flatten the $args list - # See also: http://wiki.tcl.tk/11787 - {expand} - eval assert_complete \$pick \"\$cmd \$partial\" \$test $args; #" - } -} - - # If cword contains colon (:), left-trim completions with cword # @param string $cmd Command to complete # @param list $items Reference to list of completions to trim diff --git a/test/t/test_finger.py b/test/t/test_finger.py index e3cdfacd31b..92c983fa282 100644 --- a/test/t/test_finger.py +++ b/test/t/test_finger.py @@ -4,11 +4,22 @@ class TestFinger: - @pytest.mark.complete("finger ") - def test_1(self, bash, completion): - users_at = sorted( + @pytest.fixture(scope="class") + def users_at(self, bash): + return sorted( assert_bash_exec( bash, "compgen -A user -S @", want_output=True ).split() ) + + @pytest.mark.complete("finger ") + def test_1(self, bash, completion, users_at): assert completion == users_at + + @pytest.mark.complete("finger r") + def test_2(self, bash, completion, users_at): + if not any(x.startswith("r") for x in users_at): + pytest.skip("No users starting with r") + assert completion + assert all(x.startswith("r") for x in completion) + assert not completion.endswith(" ")