-
-
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
Incorrect confcutdir inferred when rootdir is under a symlink directory #12291
Comments
It seems like The possible options that I can see:
Option 1 feels a bit dubious. It is tempting but I think it will cause other breakage... Option 2 seems wrong, the user explicitly specified a path so I think we should respect it. This leaves option 3. I'd say the best thing to do is what you did, use the resolved rootdir on your side. I'll close the issue but happy to hear other opinions. |
When a test directory is nested within a symlinked directory, it can lead to errors when the 'rootdir' or the invocation directory targets the unresolved path, especially when the symlink targets a different storage structure.
This issue does not occur when both the 'rootdir' and invocation directory use the same path (resolved or unresolved).
The invocation directory defaults to Path.cwd() which resolves the symlink, and relative entries seem to be normalized via pathlib.absolutepath (using
os.path.abspath
under the hood), which also returns a resolved path in some situations:By default, the 'confcutdir' value is inferred from the 'rootdir' value, which is inferred from the invocation path, so it doesn't seem to be a problem. But in cases where the invocation path is defined to use the resolved path, while the 'rootdir' value is defined to use the unresolved path (or vice versa), the Session collector may encounter difficulties determining where to stop when searching for configs:
pytest/src/_pytest/main.py
Lines 861 to 869 in 84e59af
This issue could be solved by automatically resolving the value used for 'rootdir', but I'm not sure if there are any drawbacks to this approach (aside from performance).
I ran these tests on MacOS and Linux using Pytest 8.2.0 and Python 3.10.
I also setup a small repository to reproduce the errors via a Github workflow for more details:
https://github.com/buddly27/pytest-issue/actions/runs/8973032152/job/24642315352
The text was updated successfully, but these errors were encountered: