-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issues with nodeid consistency when pytest --pyargs is not run from the root directory #3714
Comments
This comment has been minimized.
This comment has been minimized.
Hi, The nodeids are computed from the (sorry for the terse response, I'm on the phone) |
to expand a bit - this difference is there so that tests intended to be found with |
But the nodeids are indeed not the same (this is exactly how I found about this):
The relevant outputs are
|
thanks for the reproducer |
Consider the following (standard) test layout:
where
quux
is in PYTHONPATH (e.g., add it directly to PYTHONPATH, orquux
could actually besite-packages
).conftest.py is set to report the items nodeids:
and
test_foo
contains a single test,test_bar
If one runs
pytest --pyargs pkg
,--pyargs pkg.tests
, orpkg.tests.test_foo
, fromquux
, then the nodeid is correctly reported aspkg/tests/test_foo.py::test_bar
If one runs the same commands from
quux
's parent, then the nodeids are reported asquux/tests/test_foo.py::test_bar
-- i.e., relative to cwd rather than to where the tests have been found in the PYTHONPATH.Finally, if one runs the same commands from a directory that is unrelated (not a parent) of quux, then the nodeids are reported as
pkg/tests/test_foo.py::test_bar
,tests/test_foo.py::test_bar
, andtest_foo.py::test_bar
respectively -- i.e., relative to the parent of the last specified module.I think the correct behavior is clearly to always report as relative to where the tests have been found in the PYTHONPATH, i.e.
pkg/tests/test_foo.py::test_bar
.Tested from a fresh Py3.6 (Arch Linux repo Python) venv with just pytest 3.6.3 installed.
Seems related to #2775.
The text was updated successfully, but these errors were encountered: