I have a Python file, let's call it script1.py. I am trying to write a unit test (using unittest) called script1_test.py. script1 is meant to be called from command line and take in a number of arguments. When script 1 is run, it starts off with:
if __name__ == "__main__" and len(sys.argv) == 6:
func1()
else
print "Wrong number of arguments"
sys.exit(1)
I'm just trying to execute and test a function (here called func1) within script1 independent of the main body of the code. But when I do so, I keep hitting the sys.exit from main during the import phase. How can I run the test without hitting this error?