Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to unittest command line arguments?
    primarykey
    data
    text
    <p>I am trying to supply command line arguments to Python <code>unittest</code> and facing some issues. I have searched on internet and found a way to supply arguments as</p> <pre><code>unittest.main(argv=[myArg]) </code></pre> <p>The issue is this works fine for single command line argument but fails for more than one arguments.</p> <pre><code>unittest.main(argv=[myArg1, myArg2, myArg3]) </code></pre> <p>Above call fails with below error:</p> <pre><code> 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' </code></pre> <p>Digged more into this and found that Python <code>unittest</code> treats everything sent using <code>argv</code> as test case to be run.</p> <p>Please let me know If there's still a way to supply more than one arguement to my unit test cases. I want to override some hard coded values like IP address, test case tag etc. and essentially run this test script from within main test script.</p> <p>Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload