diff options
author | Jeff Quast <contact@jeffquast.com> | 2014-03-07 17:28:15 -0800 |
---|---|---|
committer | Jeff Quast <contact@jeffquast.com> | 2014-03-07 17:28:15 -0800 |
commit | fcf4ad9b744f845b9c88f63c735ff686f24381e2 (patch) | |
tree | 52755971d9f2d4fc6d1e4d01b3d95af53288b3fc | |
parent | 886430f6d13e8b5555bf08a1220093b3ca5fc657 (diff) | |
parent | 2ba85516dd2b95bab1674becc42326df72265d0c (diff) | |
download | pexpect-fcf4ad9b744f845b9c88f63c735ff686f24381e2.tar.gz |
Merge pull request #43 from pexpect/issue-42-cannot-implicit-bytes-to-str
closes issue #42, self.buffer decoded implicitly
-rw-r--r-- | pexpect/pxssh.py | 4 | ||||
-rw-r--r-- | tests/test_pxssh.py | 17 |
2 files changed, 18 insertions, 3 deletions
diff --git a/pexpect/pxssh.py b/pexpect/pxssh.py index a18076e..ec8c525 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,)) return True def logout (self): diff --git a/tests/test_pxssh.py b/tests/test_pxssh.py index b4994e5..0ff092c 100644 --- a/tests/test_pxssh.py +++ b/tests/test_pxssh.py @@ -1,5 +1,6 @@ #!/usr/bin/env python import os + import unittest from pexpect import pxssh @@ -26,7 +27,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 +37,17 @@ 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 + try: + ssh.login('server', 'me', password='s3cret', + auto_prompt_reset=True) + except pxssh.ExceptionPxssh: + pass + else: + assert False, 'should have raised exception, pxssh.ExceptionPxssh' + + if __name__ == '__main__': - unittest.main()
\ No newline at end of file + unittest.main() |