title: How to use pytest to pass a value in your test using command line args?
body: <p>I have the following as conftest.py --></p>
  
  <pre><code>def pytest_addoption(parser):
      parser.addoption("--browser")
      parser.addoption("--osType", help="Type of operating system")
      parser.addoption("--hostURL", action="store", help="prod, stage, or dev")
  
  @pytest.fixture(scope="session")
  def browser(request):
      return request.config.getoption("--browser")
  
  @pytest.fixture(scope="session")
  def osType(request):
      return request.config.getoption("--osType")
  
  @pytest.fixture(autouse=True)
  def hostURL(request):
      return request.config.getoption("--hostURL")
  </code></pre>
  
  <p>I would like to use the --hostURL flag to pass in value such as prod, stage or dev.</p>
  
  <p>Here's how my test_TheMainTest.py looks --></p>
  
  <pre><code>import unitest
  import pytest
  
  class CheckStatusCodeTest(unittest.TestCase, LoginPage, CustomSeleniumDriver):
  
      def test_CheckStatusCodeOfPages(self, hostURL):
          self.login(hostURL)
  </code></pre>
  
  <p>When I run the above test using pytest -q -s --hostURL prod I get the following error --></p>
  
  <pre><code>   TypeError: test_CheckStatusCodeOfCRPages() missing 1 required positional argument: 'hostURL'
  </code></pre>