I am very new to sw coding needing some help. Thank You!
- I have a script that scan a path for .py files and display it it in menu format using enumerates
- Ask user to select file/files they want to run and put them in a list
- And start ran those file from this list one by one
My issue is that it only ran the the fist selected file from the user selected list. Here is my simple code.
import os
import sys
choice_1 = ''
run_list = []
while choice_1 != 'q':
print("\nPlease select desire test case: ")
items = os.listdir("C:/Users/tonp\PycharmProjects/untitled1")
fileList = [name for name in items if name.endswith(".py")]
for cnt, fileName in enumerate(fileList, 0):
sys.stdout.write("[%d] %s\n\r" % (cnt, fileName))
choice = int(input("Select from [1-%s]: " % cnt))
choice_1 = input("Press any key to add more case or q to start running testsuite ")
run_list.append(fileList[choice])
print("These are the case/s you have selected so far :")
print(run_list)
selected_files = run_list
for x in run_list:
exec(open(c).read())