title: Argparse and unittest.main()
body: <p>I just added a graph utility to a unittest -- basically, the fully automatic version of the test just does a numerical compare, but I want a human to be able to ask for plots.</p>
  <p>Just using argparse, <code>unittest.main()</code> was choking if I used my new argument.  What I'm currently doing is checking for that argument, then deleting it from <code>sys.argv</code> which just seems <em>wrong</em>.</p>
  <p>Is there a better way to skin this cat?</p>
  <ul>
  <li>A way to tell argparse to consume arguments from sys.argv.  Probably still wrong, but it's not me doing it, so it's OK.</li>
  <li>A way to tell argparse to cough up version of sys.argv with all the &quot;used arguments&quot; taken out -- this would be cool, because it looks like <code>unittest.main()</code> will take an alternate argv.</li>
  <li>A way to tell <code>unittest.main()</code> to ignore arguments.</li>
  </ul>
  <pre><code>if __name__ == '__main__':
      parser = argparse.ArgumentParser(
          description='Test correction'
      )
      parser.add_argument(
          '--plot-results',
          help='Plot results of cal test',
          action='store_true'
      )
      args = parser.parse_args()
  
      if args.plot_results:
          while '--plot-results' in sys.argv:
              sys.argv.remove('--plot-results')
  
      unittest.main()
  </code></pre>