I would like to know which testing tools for python support the testing of interactive programs. For example, I have an application launched by:
$ python dummy_p
A good example might be the file test_embed.py of the IPython package.
There two different approaches are used:
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 already mentioned by Brian Oakley
import pexpect
# ...
child = pexpect.spawn(sys.executable, ['-m', 'IPython', '--colors=nocolor'],
env=env)
# ...
child.sendline("some_command")
child.expect(ipy_prompt)