mirror of
https://github.com/clearml/wexpect-venv
synced 2025-01-31 02:46:59 +00:00
[ADD] reporduce script for #14
This commit is contained in:
parent
3484a98cdc
commit
b27285f5ae
34
issues/i14_switch_back_error.py
Normal file
34
issues/i14_switch_back_error.py
Normal file
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user