diff options
author | Per Sandström <per.j.sandstrom@gmail.com> | 2016-06-14 15:24:56 +0200 |
---|---|---|
committer | Per Sandström <per.j.sandstrom@gmail.com> | 2016-06-14 15:24:56 +0200 |
commit | b85e0f4ec07394e862e062275766d9efdfb4bf81 (patch) | |
tree | 75a1066e1691d284df7355300329bd21e40d43f3 /tests | |
parent | ce203f54f7ae50b199226716244e3ebd759405f8 (diff) | |
download | pexpect-git-b85e0f4ec07394e862e062275766d9efdfb4bf81.tar.gz |
add test
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/fakessh/ssh | 7 | ||||
-rw-r--r-- | tests/test_pxssh.py | 9 |
2 files changed, 15 insertions, 1 deletions
diff --git a/tests/fakessh/ssh b/tests/fakessh/ssh index 28eedc4..d3259e4 100755 --- a/tests/fakessh/ssh +++ b/tests/fakessh/ssh @@ -7,6 +7,11 @@ PY3 = (sys.version_info[0] >= 3) if not PY3: input = raw_input +server = sys.argv[-1] +if server == 'noserver': + print('No route to host') + sys.exit(1) + print("Mock SSH client for tests. Do not enter real security info.") pw = getpass.getpass('password:') @@ -26,4 +31,4 @@ while True: elif cmd == 'echo $?': print(0) elif cmd in ('exit', 'logout'): - break
\ No newline at end of file + break diff --git a/tests/test_pxssh.py b/tests/test_pxssh.py index 0ff092c..3b3e50b 100644 --- a/tests/test_pxssh.py +++ b/tests/test_pxssh.py @@ -48,6 +48,15 @@ class PxsshTestCase(SSHTestBase): else: assert False, 'should have raised exception, pxssh.ExceptionPxssh' + def test_connection_refused(self): + ssh = pxssh.pxssh() + try: + ssh.login('noserver', 'me', password='s3cret') + except pxssh.ExceptionPxssh: + pass + else: + assert False, 'should have raised exception, pxssh.ExceptionPxssh' + if __name__ == '__main__': unittest.main() |