如何通过使用 easygui 选择测试一个接一个地 运行 python 脚本?

How to run python scripts one after the other by selecting the tests using easygui?

我正在使用以下代码 select 一个接一个 运行 我想要的测试。

from easygui import *
import sys,os

msg="Select following tests for testing"
title="Test Selector"
choices=["Test_case","Test_case2"]
choice=multchoicebox(msg,title,choices)


print choice
msgbox("You have selected:"+str(choice))
msg="Do you want to continue?"
title="Please confirm"
if ccbox(msg,title):
    pass
else:
    sys.exit(0)

def func():
    for tests in choice:
        print "tests",tests
    return tests
def main():

    execfile('python'+' ' +str( func())+'.py')

main()

现在在 select 测试之后我想 运行 在 other.I 之后的那些测试我正在尝试使用 execfile,但它说

IOError: [Errno 2] No such file or directory: 'python Test_case.py'

谁能帮帮我?

您不需要将 'python' 传递给文件名...

execfile('Test_case.py')  # willl work

或者你的情况

execfile(str( func())+'.py')

看这里: