-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Main and 8.0.x (not released yet): cannot find fixture when using --pyargs #11816
Comments
Weird I don't get this error on Windows (Windows 10 but I doubt this matters), Python 3.8 and either Could you try again, just to make sure it has not been fixed in It seems very similar to something that was seen in jdaviz, although that was a few days ago, in particular before #11708 was merged and that was using a custom pytest debug branch. There is a bit more context in spacetelescope/jdaviz#2654. We were at the point that |
I just tried again and the error
|
This seems indeed the case for me as well:
So So #11708 solved #9765 (assertion I'm guess all In this particular case
|
I guess to reproduce this, you need two capitalized directory names? In my case
@lesteve Can you try in a virtual environment that starts with a capital letter? (for example Also to be sure |
I actually managed to reproduce your issue inside a Git bash console with your original instructions in your top post. Previously I was using a MSYS2 console which was not showing the issue for some unknown reason. Quickly looking at your PR, you seem to be saying that there are still some places in Pytest code, where use of I would guess that since this issue was seen in jdaviz and your project ewokscore, this is likely something that a number of other projects will encounter. |
Most of the project I know have this problem in fact. For example h5py/h5py#2364 and silx-kit/silx#4043. Edit: well it doesn't really depend on the project, it depends on the module file paths. |
Indeed. I basically replace all |
I can reproduce the issue in the h5py CI: h5py/h5py#2367. I think this is a nice public way to show indeed that there is an issue, and also a quick and dirty way to double-check that this issue is fixed (in the future). You can see in this build log that all Windows builds fail with the same symptoms (fixtures are not defined). As I said above, my guess is that this will likely affect a number of projects. @bluetech ideally it would be great to fix this before cutting a 8.0.0rc2 release. @woutdenolf you probably have a good understanding of the issue, maybe it could help if you could do a quick summary. For now (sorry I did not have time to look into it closely), I get the vibe For example in #9765, the issue was that the code expected that |
The issue is here: pytest/src/_pytest/fixtures.py Lines 1486 to 1506 in 348e6de
A bit dense technical explanation, hopefully you manage to follow :) When a conftest plugin (and any other plugin) is registered, pytest calls the When you register a fixture, you need to define its "visibility" AKA When a fixture is defined in e.g. some test file, the visibility is the specific node it's defined in, e.g. the When a fixture is defined in a conftest plugin (the relevant case for this issue), the visibility logically is supposed to be the conftest's directory. In practice this is done in the code above -- the As we've already learned from #9765, relying on both Therefore, the PR I would like to see instead is to change the
@woutdenolf @lesteve It'd be great if one of you could try this and see if it indeed fixes the issue. |
The core issue is that
Of course we could mix both solutions. I'm just worried that Are there other cases than |
|
The method is not public, in fact we just broke it by adding We know that normalization can work but it brings its own risks. So in the previous issue we've decided to avoid |
I tried that suggestion
|
@bluetech So two potential fixes are
Both solve my use cases so whatever you want. |
Nice to see this one closed, thanks a lot @woutdenolf and @bluetech! I double-checked just to be sure in h5py/h5py#2367, and the problem that h5py (and other projects like jdaviz and ewokscore) was seeing is now gone from Pytest |
pip list
from the virtual environment you are usingWhile adding a comment to #9765 (comment) to reproduce that issue, I noticed another problem (not released yet, only the
main
and8.0.x
branches).Reproduce the issue
or also
Released pytest versions do not show the problem. For example this works find:
Os and python version
Error message
The error says it cannot find the
varinfo
dependency which is defined in the moduleewokscore.tests.conftest
.The text was updated successfully, but these errors were encountered: