2017-03-03 11 views
1

다음 코드를 사용하여 하나씩 실행하려는 테스트를 선택하고 있습니다.easygui를 사용하여 테스트를 선택하여 파이썬 스크립트를 차례로 실행하는 방법은 무엇입니까?

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] No such file or directory: 'python Test_case.py'

이 사람이 나를 도와주세요 수 있다고? 당신은 파일의 이름으로 'python'를 통과 할 필요가없는

+0

왜 임포트하지 않습니까? 그리고 이것을 사용하려고하면''python "+" "' – abccd

+0

tmp = importlib.import_module (tests)을 제거해야합니다. 첫 번째 스크립트 만 실행하면 모든 스크립트에 대해 어떻게 실행해야합니까? – user1681102

답변