-
-
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
Preserve symlinks #5266
Comments
Sounds sensible. Is there another way that wouldn't require a flag? IIRC I've started with that to make A minimal example would be great to have. |
The way bazel executes But yeah will work on a repro asap. |
Here is a minimal example not involving bazel: https://github.com/Globegitter/pytest-repro |
Might be a good compromise. But it is also about internal lookup of contests etc (from parent dirs), and that would then mean to still resolve them internally at least in those places. It happens here: Line 710 in c8f7e50
It was done for #4325 via #4337. |
Started working on it in #5270 (8 failures IIRC). Some question came up already: how should nodes be reported? Using the symlink or target? ( pytest/testing/test_collection.py Line 1134 in c8f7e50
|
Thanks for the quick progress! Just tested it out and it does indeed work as expected - great. When you say "how should nodes be reported", do you mean which path it should report, when it prints to stdout?
I think in this case either or is fine, but I would prefer the symlink path, the behaviour it seems to be now as I can tell. That would imo also fit the behaviour of "preserve symlinks". |
@blueyed is there anything I can do to push this forward? Happy to also put in some time myself if I know what the best way forward is. |
Yes - basically how the nodeid should look like (that gets used internally also, including for test selection). You could pick up my branch and make the failing tests work there, I assume that the resolving has to be done in a more inner place now - possibly only temporarily. |
@Globegitter |
I came across the same problem. |
Any updates on this? I am getting 0% coverage. Thanks |
We have since then changed pytest and I think we do respect symlinks now: we no longer use @aditya-qure can you post a MWE? |
It seems over the time pytest introduced
realpath
calls to resolve symlinks. When trying to use pytest with https://bazel.build/ however that falls flat because is executing all tests in an isolated sandbox (think lightweight docker) and is for performance reason just symlinking files rather than copying them and it expects tools to respect symlinks. Further it only puts the files into the sandbox that it needs for that test, so it might just be the pytest dependency, the testfile itself and the library that is needed for it. The problem I am now facing is, that pytest is resolving the symlink of the testfile, ending up in my real project directory, discovering a__init__.py
file there and then complaining about missing imports because the isolated python provided by bazel does not have access to these for running the test.It would be nice to get an option for pytest to just treat symlinks as the real files and not try to resolve them. In the nodejs world for example the flag
--preserve-symlinks
exists for that and it would be great to get the same for pytest.Let me know if you need a minimal reproduction case, then I am happy to provide one.
pytest version 4.4.2, OS: Elementary OS 5 (Ubuntu 18.04)
The text was updated successfully, but these errors were encountered: