title: Python, unit test - Pass command line arguments to setUp of unittest.TestCase
body: <p>I have a script that acts as a wrapper for some unit tests written using the Python <code>unittest</code> module. In addition to cleaning up some files, creating an output stream and generating some code, it loads test cases into a suite using</p>
  <pre><code>unittest.TestLoader().loadTestsFromTestCase()
  </code></pre>
  <p>I am already using <code>optparse</code> to pull out several command-line arguments used for determining the output location, whether to regenerate code and whether to do some clean up.  I also want to pass a configuration variable, namely an endpoint URI, for use within the test cases.</p>
  <p>I realize I can add an <code>OptionParser</code> to the setUp method of the TestCase, but I want to instead pass the option to <code>setUp</code>.  Is this possible using <code>loadTestsFromTestCase()</code>?  I can iterate over the returned <code>TestSuite</code>'s <code>TestCases</code>, but can I manually call setUp on the <code>TestCases</code>?</p>
  <p>** EDIT **
  I wanted to point out that I am able to pass the arguments to <code>setUp</code> if I iterate over the tests and call <code>setUp</code> manually like:</p>
  <pre><code>(options, args) = op.parse_args()
  suite = unittest.TestLoader().loadTestsFromTestCase(MyTests.TestSOAPFunctions)
  for test in suite:
      test.setUp(options.soap_uri)
  </code></pre>
  <p>However, I am using <code>xmlrunner</code> for this and its run method takes a <code>TestSuite</code> as an argument.  I assume it will run the setUp method itself, so I would need the parameters available within the <code>XMLTestRunner</code>.</p>