title: Mutually exclusive groups of arguments?
body: <p>I have a single Python file which includes unit tests in the source code. It works like this:</p>
  
  <pre><code>parser = argparse.ArgumentParser()
  parser.add_argument('--test', action='store_true', help="Run unit tests and return.")
  
  args = parser.parse_args()
  
  if args.test:
      testsuite = unittest.TestLoader().loadTestsFromTestCase(SanitizeTestCase)
      unittest.TextTestRunner(verbosity=1).run(testsuite)
  </code></pre>
  
  <p>If <code>args.test</code> is false, the program runs as expected. I don't want to have to make this into an entire <code>setuptools</code> project, it's a pretty simple script with some unit tests to evaluate that it does what it's supposed to.</p>
  
  <p>I now find myself needing to parse other arguments, and that's where things start to fall apart. <code>--test</code> is a mutually exclusive parameter and all of the other parameters don't apply if <code>--test</code> is passed.</p>
  
  <p>Is there a way to have mutually-exclusive argument groups in argparse?</p>