diff options
-rw-r--r-- | pexpect/pxssh.py | 4 | ||||
-rw-r--r-- | tests/test_pxssh.py | 11 |
2 files changed, 12 insertions, 3 deletions
diff --git a/pexpect/pxssh.py b/pexpect/pxssh.py index a18076e..69021b4 100644 --- a/pexpect/pxssh.py +++ b/pexpect/pxssh.py @@ -320,7 +320,9 @@ class pxssh (spawn): if auto_prompt_reset: if not self.set_unique_prompt(): self.close() - raise ExceptionPxssh('could not set shell prompt\n'+self.before) + raise ExceptionPxssh('could not set shell prompt ' + '(recieved: %r, expected: %r).' % ( + self.before, self.PROMPT_SET_SH,)) return True def logout (self): diff --git a/tests/test_pxssh.py b/tests/test_pxssh.py index b4994e5..0ee5bf5 100644 --- a/tests/test_pxssh.py +++ b/tests/test_pxssh.py @@ -26,7 +26,7 @@ class PxsshTestCase(SSHTestBase): ssh.expect('pong', timeout=10) assert ssh.prompt(timeout=10) ssh.logout() - + def test_wrong_pw(self): ssh = pxssh.pxssh() try: @@ -36,5 +36,12 @@ class PxsshTestCase(SSHTestBase): else: assert False, 'Password should have been refused' + def test_failed_set_unique_prompt(self): + ssh = pxssh.pxssh() + ssh.set_unique_prompt = lambda: False + with self.assertRaises(pxssh.ExceptionPxssh): + ssh.login('server', 'me', password='s3cret', + auto_prompt_reset=True) + if __name__ == '__main__': - unittest.main()
\ No newline at end of file + unittest.main() |