1

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?

ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97
user1681102
  • 193
  • 2
  • 4
  • 13
  • why dont instread exec it you import it? And you should get rid of `"python"+" "` – Taku Mar 03 '17 at 15:58
  • tmp=importlib.import_module(tests) if i try to use this it is running only first script,how do I have to make it run for all scripts? – user1681102 Mar 03 '17 at 16:57

1 Answers1

1

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:

linusg
  • 6,289
  • 4
  • 28
  • 78
ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97