1

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

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()

现在选择测试后,我想一个接一个地运行这些测试。我正在尝试使用 execfile,但它说

IOError:[Errno 2] 没有这样的文件或目录:'python Test_case.py'

谁能帮帮我吗?

4

1 回答 1

1

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

execfile('Test_case.py')  # willl work

或者在你的情况下

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

看这里:

于 2017-03-03T15:57:16.917 回答