def run_script(self, input="", args=("-",), substfile="xx yy\n"):
substfilename = test_support.TESTFN + ".subst"
with open(substfilename, "w") as file:
file.write(substfile)
self.addCleanup(test_support.unlink, substfilename)
argv = ["fixcid.py", "-s", substfilename] + list(args)
script = os.path.join(scriptsdir, "fixcid.py")
with test_support.swap_attr(sys, "argv", argv), \
test_support.swap_attr(sys, "stdin", StringIO(input)), \
test_support.captured_stdout() as output:
try:
runpy.run_path(script, run_name="__main__")
except SystemExit as exit:
self.assertEqual(exit.code, 0)
return output.getvalue()
评论列表
文章目录