Skip to content

Commit

Permalink
test: port some more ssh test case to pytest+pexpect
Browse files Browse the repository at this point in the history
  • Loading branch information
scop committed Apr 20, 2019
1 parent 6fa7458 commit d2bec62
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 24 deletions.
24 changes: 0 additions & 24 deletions test/lib/completions/ssh.exp
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,6 @@ proc teardown {} {
setup


set test "Tab should complete both commands and hostname"
# Try completion
set cmd "ssh -F config ls"
send "$cmd\t"
set expected "^$cmd\r\n.*ls.*ls_known_host.*\r\n/@$cmd$"
expect {
-re $expected { pass "$test" }
-re /@ { unresolved "$test at prompt" }
default { unresolved "$test" }
}


sync_after_int


set test "-F without space shouldn't error"
# Try completion
set cmd "ssh -F"
Expand All @@ -50,15 +35,6 @@ expect {
sync_after_int


set test "First argument shouldn't complete with commands"
# NOTE: This test assumes there's a command "bash" and no host named "bash"
set cmd "ssh bas"
assert_complete [get_known_hosts "bas"] $cmd $test


sync_after_int


set test "First argument 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 (:).
Expand Down
14 changes: 14 additions & 0 deletions test/t/test_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,17 @@ class TestSsh:
@pytest.mark.complete("ssh -Fsp", cwd="ssh")
def test_1(self, completion):
assert completion == "-Fspaced conf"

@pytest.mark.complete("ssh -F config ls", cwd="ssh")
def test_2(self, completion):
"""Should complete both commands and hostname."""
assert all(x in completion for x in "ls ls_known_host".split())

@pytest.mark.complete("ssh bash", cwd="ssh")
def test_3(self, completion):
"""
First arg should not complete with commands.
Assumes there's no "bash" known host.
"""
assert "bash" not in completion

0 comments on commit d2bec62

Please sign in to comment.