2017-03-03 22 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'

任何人都可以幫我嗎?

+0

爲什麼不會將exec導入它呢?你應該擺脫'「python」+「」' – abccd

+0

tmp = importlib.import_module(測試)如果我嘗試使用它,它只運行第一個腳本,我該如何讓它運行所有腳本? – user1681102

回答

相關問題