title: Passing args to nose.runmodule()
body: <p>I switched from unittest to nose to be able to specify concurrent processing and xunit report generation. My python file contains several test functions and a nontest function that the test functions call during testing. I know that tests should be automated to the point that no arguments need to be passed in, when testing. However, I want to the user be able to change the defaults, if he so wishes. So, I use argparse to parse the arguments. Following is a sample of the test script. I haven't included several other test functions present in the original file.</p>
  
  <pre><code>from selenium import webdriver
  from nose.tools import nottest
  from nose.tools import assert_equals
  import nose
  import unittest
  import argparse
  import sys
  
  @nottest
  def open_browser():
      browser = eval('webdriver.%s()'%browserType)
      return browser
  
  def test_google_title():
      browser = open_browser()
      browser.get("http://www.google.com")
      assert_equals("Google", browser.title)
      browser.quit()
  
  def test_yahoo_title():
      browser = open_browser()
      browser.get("http://www.yahoo.com")
      assert_equals("Yahoo", browser.title)
      browser.quit()
  
  if __name__ == "__main__":
      parser = argparse.ArgumentParser()
      parser.add_argument("--browser", choices=['PhantomJS', 'Chrome'],default='PhantomJS')
      args, unknown = parser.parse_known_args()
      browserType = args.browser
  
      try:
          sys.argv.remove('--browser')
          sys.argv.remove(args.browser)
      except ValueError:
          pass
  
      nose.runmodule()
  </code></pre>
  
  <p>I read args.browser into browserType, which is later used by open_browser(). When I run,</p>
  
  <pre><code>python test.py --browser 'Chrome' -v --with-xunit
  </code></pre>
  
  <p><strong>It runs fine</strong>. </p>
  
  <p>However, when I run,</p>
  
  <pre><code>python test.py --browser 'Chrome' -v --with-xunit --processes 2 --process-timeout 10
  </code></pre>
  
  <p><strong>It fails with the error</strong>,</p>
  
  <pre><code>Traceback (most recent call last):
    File "/Users/indrajeet/.virtualenv/virtualenv/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
      self.test(*self.arg)
    File "/Users/indrajeet/scripts/test.py", line 15, in test_google_title
      browser = open_browser()
    File "/Users/indrajeet/scripts/test.py", line 11, in open_browser
      browser = eval('webdriver.%s()'%browserType)
  NameError: global name 'browserType' is not defined
  </code></pre>
  
  <p>I need the flexibility to pass in additional options to nose such as --processes, --process-timeout without having to specify them in parser.</p>
  
  <p>Any ideas? Thanks for reading...</p>