[英]How do I run a python script to test my own shell?
I am making my own shell and I want to make a python script to automate tests.我正在制作自己的 shell,我想制作一个 python 脚本来自动化测试。 I would like to run both programs like this: ./my_shell | test.py
我想像这样运行这两个程序: ./my_shell | test.py
./my_shell | test.py
How can I do that ?我怎样才能做到这一点 ?
import os
def command(command):
exit_status = os.system(
"echo \"%s\" | ./42sh > output 2> errout" % command)
with open("output", "r") as output_file:
output = output_file.read()
with open("errout", "r") as error_file:
error = error_file.read()
return output, error, exit_status / 256
out, err, ex = command("ls -a")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.