2017-03-03 5 views
1

私は次々に実行したいテストを選択するために次のコードを使用しています。easyguiを使ってテストを選択して、Pythonスクリプトを順番に実行するには?

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

は、今私はother.I次々にexecfileをを使用しようとしていますこれらのテストを実行するテストを選択した後、それは

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

は誰も私を助けてくださいと言いますか?あなたは、ファイルの名前に'python'を渡す必要がいけない

+0

なぜexecをインスツルしてインポートしないのですか?そして、これを使用しようとすると '' python "+" "' – abccd

+0

tmp = importlib.import_module(tests)を取り除くべきです。最初のスクリプトのみを実行していますが、どのようにすべてのスクリプトを実行する必要がありますか? – user1681102

答えて

関連する問題