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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/pexpect/tests/test_FSM.py
diff --git a/third_party/pexpect/tests/test_FSM.py b/third_party/pexpect/tests/test_FSM.py
new file mode 100644
index 0000000000000000000000000000000000000000..3425fd2110e370ff711aef440fa7090a8d1febe3
--- /dev/null
+++ b/third_party/pexpect/tests/test_FSM.py
@@ -0,0 +1,34 @@
+import io
+import sys
+import unittest
+try:
+ import builtins
+except ImportError:
+ import __builtin__ as builtins
+
+PY3 = (sys.version_info[0] >= 3)
+input_name = 'input' if PY3 else 'raw_input'
+
+from pexpect import FSM
+
+class FSMTestCase(unittest.TestCase):
+ def test_run_fsm(self):
+ def _input(prompt):
+ return "167 3 2 2 * * * 1 - ="
+ orig_input = getattr(builtins, input_name)
+ orig_stdout = sys.stdout
+ setattr(builtins, input_name, _input)
+ sys.stdout = sio = (io.StringIO if PY3 else io.BytesIO)()
+
+ try:
+ FSM.main()
+ finally:
+ setattr(builtins, input_name, orig_input)
+ sys.stdout = orig_stdout
+
+ printed = sio.getvalue()
+ assert '2003' in printed, printed
+
+
+if __name__ == '__main__':
+ unittest.main()
« 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