Search code examples
pythonruntime-errorprogram-entry-pointeasyguiexecfile

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


I am using the following code to select the tests i want to run one after the another.

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

Now after selecting the tests i want to run those tests one after the other.I am trying to use execfile, but it says

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

Can anyone please help me?


Solution

  • You dont need to pass the 'python' to the name of the file...

    execfile('Test_case.py')  # willl work
    

    or in your case

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

    Look here: