test_cli.py 文件源码

python
阅读 35 收藏 0 点赞 0 评论 0

项目:reframe 作者: eth-cscs 项目源码 文件源码
def run_command_inline(argv, funct, *args, **kwargs):
    argv_save = sys.argv
    environ_save = EnvironmentSnapshot()
    captured_stdout = StringIO()
    captured_stderr = StringIO()
    sys.argv = argv
    exitcode = None
    with redirect_stdout(captured_stdout):
        with redirect_stderr(captured_stderr):
            try:
                exitcode = funct(*args, **kwargs)
            except SystemExit as e:
                exitcode = e.code
            finally:
                # restore environment, command-line arguments, and the native
                # modules system
                environ_save.load()
                sys.argv = argv_save
                fixtures.init_native_modules_system()

    return (exitcode,
            captured_stdout.getvalue(),
            captured_stderr.getvalue())
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号