title: How to use a command line argument in unittest?
body: <p>For some reason I'm having issues trying to use command line arguments with my unittests.</p>
  
  <p>Simply put, all I want is to use env with all my tests.  What am I doing wrong here?</p>
  
  <pre><code># -*- coding: utf-8 -*-
  import argparse
  from selenium import webdriver
  from selenium.webdriver import ActionChains
  from selenium.webdriver.common.by import By
  from selenium.webdriver.support.ui import WebDriverWait
  from selenium.webdriver.support import expected_conditions as EC
  from selenium.webdriver.common.keys import Keys
  import unittest, time, re
  
  class mySmokeTest(unittest.TestCase):
      def __init__(self, args):
          self.env = args.env
  
      def setUp(self):
          self.driver = webdriver.Firefox()
          self.base_url = "http://google.com"
          self.verificationErrors = []
          self.accept_next_alert = True
  
      def test_add_to_cart(self, env):
          # open base page
          driver = self.driver                    
          driver.get("{0}".format(env))
  
      def tearDown(self):
          self.driver.quit()
          self.assertEqual([], self.verificationErrors)
  
  if __name__ == "__main__":
      parser = argparse.ArgumentParser()
      parser.add_argument('env', default='environment to test against')
      args = parser.parse_args()
      env = args.env
      runner = unittest.TextTestRunner()
      itersuite = unittest.TestLoader().loadTestsFromTestCase(mySmokeTest)
      runner.run(itersuite)
  </code></pre>
  
  <p>error:</p>
  
  <pre><code>self.env = args.env
  AttributeError: 'str' object has no attribute 'env'
  </code></pre>