I am running my scripts on python 2.6. The requirement is as mentioned below.
There are some 100 test scripts (all python scripts) in one directory. I have to create one master python script which will start running all the 100 test scripts one by one and then I have to display whether test case is failed or not. Every script will call sys.exit() to finish the execution of script. Currently I am reading the sys.exit() value from the master script and I am determining whether the particular test case is failed or not.
But now there is a requirement change that I have to display the log file name also (log files will be created when I run scripts). So can I send a tuple as argument (which contains status as well as log file name) to sys.exit() instead of sending integer value?
I have read on net that if we pass an argument other than integer, None is equivalent to passing zero, and any other object is printed to stderr and results in an exit code of 1. So if I pass a tuple as an argument, will os consider as failure even in success case also as I am not passing None?
I am using subprocess.popen() in my master script to run the scripts and I am using format() to read the sys.exit() value.
Yes, you are correct. Passing a tuple will print the tuple to stderr and return with a exit code of 1. You must return None to denote success.
Notice this is a convention of shells and the like and is not required. That being said the conventions are in place for a very, very good reason.
Can we send a tuple as an argument to sys.exit() in python