I have an interactive program that runs stdin and stdout. I need to create wrapper that will send X to it\'s stdin, check that it prints Y and then redirects wrapper\'s stdin an
You can overwrite the sys module's stdin and stdout
import sys sys.stdin, sys.stdout = wrapper.stdin, wrapper.stdout
These need to be file objects opened for reading and writing respectively. The original stdin and stdout are found at
sys.stdin, sys.stdout = sys.__stdin__, sys.__stdout__