title: pytest - unrecognized argument on cli invocation, despite being defined
body: <p><em>This works on Windows without problems, but crashes on Linux.</em></p>
  
  <pre><code>python setup.py test --addopts '--config myconf.ini'
  </code></pre>
  
  <hr>
  
  <p>I have defined a custom argument for testing to provide a test user credentials via a config file:</p>
  
  <p><strong><code>tests/conftest.py</code>:</strong></p>
  
  <pre><code>def pytest_addoption(parser):
      parser.addoption('--config', default='conf.ini', help='Path to the testing config file.')
  
  
  @pytest.fixture(scope='session')
  def configfile(request):
      return request.config.getoption("--config")
  </code></pre>
  
  <p>This is how I use it in testing files:</p>
  
  <pre><code>def test_foo(configfile):
      print(configfile)
  </code></pre>
  
  <hr>
  
  <p>On Windows, this works fine. On Linux, however, I get this (setup.cfg is configured to invoke pytest, so this is pytest's err output)</p>
  
  <pre><code>usage: setup.py [options] [file_or_dir] [file_or_dir] [...]
  setup.py: error: unrecognized arguments: --config
    inifile: None
    rootdir: /uupmaker
  </code></pre>
  
  <p>What is interesting though, if I pass a filename to <code>--config fn</code> that <em>does not exist</em>, no error is thrown and the tests run normally (albeit as if there was no config file defined).</p>
  
  <p>Have I overlooked something? Why won't this work?</p>
  
  <hr>
  
  <p>Edit: <code>pip freeze --all</code> output:</p>
  
  <pre><code>certifi==2017.7.27.1
  chardet==3.0.4
  colorama==0.3.9
  coverage==4.4.1
  defusedxml==0.5.0
  idna==2.6
  jenkinsapi==0.3.4
  jira==1.0.10
  lxml==3.8.0
  oauthlib==2.0.3
  pbr==3.1.1
  pip==9.0.1
  py==1.4.34
  pytest==3.2.2
  pytest-runner==2.12.1
  python-dateutil==2.6.1
  pytz==2017.2
  reaver==0.1.5
  requests==2.18.4
  requests-oauthlib==0.8.0
  requests-toolbelt==0.8.0
  setuptools==28.8.0
  six==1.10.0
  teamcity-messages==1.21
  urllib3==1.22
  </code></pre>
  
  <p>Using <code>Python 3.6.1</code></p>
  
  <p><code>setup.cfg</code>:</p>
  
  <pre><code>[aliases]
  test=pytest
  </code></pre>
  
  <hr>
  
  <p>This is the minimal working example for me: <a href="https://github.com/melkamar/pytest-setuppy-err" rel="nofollow noreferrer">https://github.com/melkamar/pytest-setuppy-err</a></p>
  
  <p>Simply clone that folder and run <code>python3 setup.py test --addopts "-s --config foo.bar"</code> and it <em>should</em> fail on Linux.</p>