Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(272)

Side by Side Diff: third_party/pexpect/tests/test_pxssh.py

Issue 1398903002: Add third_party/pexpect (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@end-to-end-test
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 import os
3
4 import unittest
5
6 from pexpect import pxssh
7
8 class SSHTestBase(unittest.TestCase):
9 def setUp(self):
10 self.orig_path = os.environ.get('PATH')
11 fakessh_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), 'f akessh'))
12 os.environ['PATH'] = fakessh_dir + \
13 ((os.pathsep + self.orig_path) if self.orig_path else '')
14
15 def tearDown(self):
16 if self.orig_path:
17 os.environ['PATH'] = self.orig_path
18 else:
19 del os.environ['PATH']
20
21 class PxsshTestCase(SSHTestBase):
22 def test_fake_ssh(self):
23 ssh = pxssh.pxssh()
24 #ssh.logfile_read = sys.stdout # DEBUG
25 ssh.login('server', 'me', password='s3cret')
26 ssh.sendline('ping')
27 ssh.expect('pong', timeout=10)
28 assert ssh.prompt(timeout=10)
29 ssh.logout()
30
31 def test_wrong_pw(self):
32 ssh = pxssh.pxssh()
33 try:
34 ssh.login('server', 'me', password='wr0ng')
35 except pxssh.ExceptionPxssh:
36 pass
37 else:
38 assert False, 'Password should have been refused'
39
40 def test_failed_set_unique_prompt(self):
41 ssh = pxssh.pxssh()
42 ssh.set_unique_prompt = lambda: False
43 try:
44 ssh.login('server', 'me', password='s3cret',
45 auto_prompt_reset=True)
46 except pxssh.ExceptionPxssh:
47 pass
48 else:
49 assert False, 'should have raised exception, pxssh.ExceptionPxssh'
50
51
52 if __name__ == '__main__':
53 unittest.main()
OLDNEW
« no previous file with comments | « third_party/pexpect/tests/test_popen_spawn.py ('k') | third_party/pexpect/tests/test_replwrap.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698