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

Side by Side Diff: third_party/pexpect/tests/test_FSM.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
« no previous file with comments | « third_party/pexpect/tests/swapcase_echo.py ('k') | third_party/pexpect/tests/test_ansi.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 import io
2 import sys
3 import unittest
4 try:
5 import builtins
6 except ImportError:
7 import __builtin__ as builtins
8
9 PY3 = (sys.version_info[0] >= 3)
10 input_name = 'input' if PY3 else 'raw_input'
11
12 from pexpect import FSM
13
14 class FSMTestCase(unittest.TestCase):
15 def test_run_fsm(self):
16 def _input(prompt):
17 return "167 3 2 2 * * * 1 - ="
18 orig_input = getattr(builtins, input_name)
19 orig_stdout = sys.stdout
20 setattr(builtins, input_name, _input)
21 sys.stdout = sio = (io.StringIO if PY3 else io.BytesIO)()
22
23 try:
24 FSM.main()
25 finally:
26 setattr(builtins, input_name, orig_input)
27 sys.stdout = orig_stdout
28
29 printed = sio.getvalue()
30 assert '2003' in printed, printed
31
32
33 if __name__ == '__main__':
34 unittest.main()
OLDNEW
« no previous file with comments | « third_party/pexpect/tests/swapcase_echo.py ('k') | third_party/pexpect/tests/test_ansi.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698