A good example is the IPython test_embed.py file.
Two different approaches are used there:
subprocess
import subprocess # ... subprocess.Popen(cmd, env=env, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = p.communicate(_exit_cmd_string)
pexpect (as mentioned by Brian Oakley
import pexpect
cknoll Jun 12 '19 at 10:12 2019-06-12 10:12
source share