Open tucked opened 4 years ago
The example does not seem to repro without the second custom option (i.e. --bar
).
I cannot reproduce using your example
I can still reproduce with pytest 5.4.3 and 6.2.5 (on py36 and py39).
can you share a git repo or zip? what shell are you using?
Try this: https://github.com/tucked/pytest-7380
Shell is Bash 4.4.20(1)-release
seems pytest is detecting the --foo
argument as the test collection root instead of treating it as an unknown argument in the initial argument parsing -- this prevents it from finding your deep conftest file (pytest path
also skips the conftest)
If a custom option is defined in a
conftest.py
that is more than 1 directory below$PWD
, that option is not discovered if the parameter to that option contains a space.pip list
from the virtual environment you are usingThis was originally reproduced with Python 2.7.15+ and pytest 4.6.11.
[x] minimal example if possible
test_fail.py
is a misnomer. The test willpass
.path/to/some/tests/test_fail.py . [100%]
========================================================== 1 passed in 0.01s ==========================================================
$ venv/bin/pytest --foo="what ever" --bar=baz path/to/some/tests/ ERROR: usage: pytest [options] [file_or_dir] [file_or_dir] [...] pytest: error: unrecognized arguments: --bar=baz path/to/some/tests/ inifile: None rootdir: /tmp/tmp.iNSbiDWuuE
$ mv path/to/some/tests/ . $ venv/bin/pytest --foo="what ever" --bar=baz tests/ ========================================================= test session starts =========================================================platform linux -- Python 3.6.8, pytest-5.4.3, py-1.8.2, pluggy-0.13.1 rootdir: /tmp/tmp.iNSbiDWuuE collected 1 item
tests/test_fail.py . [100%]
========================================================== 1 passed in 0.01s ==========================================================