pytest: Command line parsing fails when path is a value for an option
On Mac OS X 10.10.4 using the latest homebrew Python 2.7.10, and py.test 2.7.2, if type on the command line:
py.test --app ~/path/to/app --host http://localhost:4444 tests/mobile
I get the following error:
usage: py.test [options] [file_or_dir] [file_or_dir] [...]
py.test: error: unrecognized arguments: --app --host http://localhost:4444 tests/mobile
This seems to be an issue regardless of OS or Python version.
This only works if I put the path as a last option. But this defeats the purpose of having options that can be set in “any” order.
This is a section of my conftest.py:
def pytest_addoption(parser):
parser.addoption('--host', action='store', help='Webdriver Remote Host')
parser.addoption('--base_url', action='store', help='base URL')
parser.addoption('--app', action='store', help='path to iOS app')
parser.addoption('--android_app', action='store', help='path to Android app')
Things to note: A full path name works okay, but it seems that a ~ and a $varialbe will fail to parse.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 17 (12 by maintainers)
I’m seeing this issue with pytest ≥ 2.8.0 with a plugin (not a conftest.py). The plugin I’m using is pytest-variables, but pytest-html is also affected. The argument values appear to be used for determining the root directory.