I am trying to provide Python unittest command line unittest and run into some problems. I searched the web and found a way to provide arguments like
unittest.main(argv=[myArg])
The problem is that this works great for a single command line argument, but not for more than one argument.
unittest.main(argv=[myArg1, myArg2, myArg3])
The call above with the error below:
File "/opt/python2.6.6/lib/python2.6/unittest.py", line 816, in __init__ self.parseArgs(argv) File "/opt/python2.6.6/lib/python2.6/unittest.py", line 843, in parseArgs self.createTests() File "/opt/python2.6.6/lib/python2.6/unittest.py", line 849, in createTests self.module) File "/opt/python2.6.6/lib/python2.6/unittest.py", line 613, in loadTestsFromNames suites = [self.loadTestsFromName(name, module) for name in names] File "/opt/python2.6.6/lib/python2.6/unittest.py", line 584, in loadTestsFromName parent, obj = obj, getattr(obj, part) AttributeError: 'module' object has no attribute 'admin'
Dig even more and find out that Python unittest handles everything sent with argv as a test case to run.
Please let me know if there is another way to suggest more than one argument in my unit test cases. I want to override some hardcoded values, such as IP address, test tag tag, etc. And essentially run this script test from the main script test.
Thanks in advance.