title: Parse commandline args in unittest python
body: <p>I am creating a test case in python using unittest module.</p>
  
  <p>I did create a parsing argument list that i want to get from user.
  But when i use that argument while executing the python script, it gives error: "option -i not recognized
  Usage: testing.py [options] [test] [...]"</p>
  
  <p>code snippet:</p>
  
  <pre><code>class Testclass(unittest.TestCase):
  
      @classmethod
      def setUpClass(cls):
          print "Hello Class"
  
      def test_addnum(self):
          print "Execute the test case"
          #parser = parse_args(['-i'])
          print 'simple_value     =', args.inputfile
  
      def parse_args():
          parser = argparse.ArgumentParser()
          parser.add_argument('-i', help='input file', dest='inputfile')
          ns, args = parser.parse_known_args(namespace=unittest)
          #args = parser.parse_args()
          return ns, sys.argv[:1] + args
  
  if __name__ == '__main__':
      unittest.main()
  </code></pre>
  
  <p>The error m getting on executing the above script with <code>-i somefile.txt</code> is:</p>
  
  <pre><code>option -i not recognized
  Usage: testing.py [options] [test] [...]
  
  Options:
    -h, --help       Show this message
    -v, --verbose    Verbose output
    -q, --quiet      Minimal output
    -f, --failfast   Stop on first failure
    -c, --catch      Catch control-C and display results
    -b, --buffer     Buffer stdout and stderr during test runs
  
  Examples:
    testing.py                               - run default set of tests
    testing.py MyTestSuite                   - run suite 'MyTestSuite'
    testing.py MyTestCase.testSomething      - run MyTestCase.testSomething
    testing.py MyTestCase                    - run all 'test*' test methods
                                                 in MyTestCase
  </code></pre>
  
  <p>Any help would be appreciated.</p>