From b27285f5aee51f1a56c364965d3acd6eab1adb2d Mon Sep 17 00:00:00 2001 From: Benedek Racz Date: Wed, 13 Nov 2019 18:06:52 +0100 Subject: [PATCH] [ADD] reporduce script for #14 --- issues/i14_switch_back_error.py | 34 +++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 issues/i14_switch_back_error.py diff --git a/issues/i14_switch_back_error.py b/issues/i14_switch_back_error.py new file mode 100644 index 0000000..05241f3 --- /dev/null +++ b/issues/i14_switch_back_error.py @@ -0,0 +1,34 @@ +import wexpect +import time + +def switch_back_error (): + p2 = wexpect.spawn('echo blabla') + + # This is an essential wait: + time.sleep(1) + p2.expect(wexpect.EOF) + + + # Path of cmd executable: + cmd_exe = 'cmd' + cmdPrompt = '>' + + # Start the child process + p = wexpect.spawn(cmd_exe) + + # Wait for prompt + p.expect(cmdPrompt) + + # Send a command + p.sendline('echo hello') + p.expect(cmdPrompt) + + p.interact() + time.sleep(2) + + if 'hello' != p.before.splitlines()[1]: + raise Exception("'hello' != p.before.splitlines()[1]") + +if __name__ == '__main__': + switch_back_error() +