-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Tests discovery failing on symlink folder #20718
Comments
Could you share your configuration for your poetry environment? Thanks |
Sure, here's the output from
|
Hi, can you also send logs from the python output? Sorry I forgot that in my first message. You can get these by going to view -> output -> and select python from the dropdown on the right. Thanks! |
No problem, it's as follows:
|
I have the same issue, where the the test tab won't discover my pytest inside the "tests" folder. I have a feeling it is because get_current_traceback changed to DebugTraceback. ImportError: cannot import name 'get_current_traceback' from 'werkzeug.debug.tbtools' (C:\Users\myuser\Miniconda3\envs\analytics\lib\site-packages\werkzeug\debug\tbtools.py)
ERROR conda.cli.main_run:execute(49): `conda run python c:\Users\myuser\.vscode\extensions\ms-python.python-2022.20.2\pythonFiles\get_output_via_markers.py c:\Users\myuser\.vscode\extensions\ms-python.python-2022.20.2\pythonFiles\testing_tools\run_adapter.py discover pytest -- --rootdir c:\Users\myuser\Documents\Git Repos\battery_placement_opt_py -s --cache-clear tests` failed. (See above for error) |
@corey-dawson can you file a separate issue, since you are using conda and not poetry. Thanks! |
@eleanorjboyd Please let me know if there's anything further you need |
Hi @ZacCranko, can you please run this from your command line and see if it returns the expected output |
Looks like Can you confirm I've run it correctly (I added the run_adapter prefix). Also I'm not sure what you mean about disabling colour on the output, if you explain to me what you want me to try I'm happy to give it a go. |
will do |
@ZacCranko, no need to append the run_adapter prefix can you try it like this |
I needed the The output of ➜ github_test_discovery_issue poetry run python -m pytest --rootdir . -s --cache-clear
================================= test session starts =================================
platform linux -- Python 3.8.10, pytest-7.2.1, pluggy-1.0.0
rootdir: /mnt/disks/persist/code/github_test_discovery_issue
collected 1 item
tests/test_foo.py .
================================== 1 passed in 0.01s ================================== |
I am not an expert on the python vscode extension but it appears in the python output, vscode is internally running the following command to detect the tests:
where the prefix [
{
"rootid": ".",
"root": "/mnt/disks/persist/code/github_test_discovery_issue",
"parents": [
{
"id": "./tests",
"kind": "folder",
"name": "tests",
"parentid": ".",
"relpath": "./tests"
},
{
"id": "./tests/test_foo.py",
"kind": "file",
"name": "test_foo.py",
"parentid": "./tests",
"relpath": "./tests/test_foo.py"
}
],
"tests": [
{
"id": "./tests/test_foo.py::test_foo",
"name": "test_foo",
"source": "./tests/test_foo.py:1",
"markers": [],
"parentid": "./tests/test_foo.py"
}
]
}
] |
Hi there, any update on this @eleanorjboyd @karthiknadig ? |
Hi! We are still unable to see this on our side- could you share your current project or a minimal repro? |
Hi, no problem. Please see attached. |
Hi, Following the steps described in this thread, I can confirm that when running the I am not using poetry but a nominal pyproject.toml setup. The project lives inside WSL and I am connecting to it via the WSL remote functionality. The vscode version that I am using:
|
@Jerry-Ma are you able to reproduce the bug with the example project I provided above? |
Hi @ZacCranko, thank you for the minimal repro! I gave it a try outside of poetry and it worked for me. Does it work if you are not in your poetry environment? I will now give it a try with poetry but wanted to check in the meantime. Thanks |
Hello again! Here are the steps I took and I could not repro the issue.
Do any of these steps sound incorrect to your process or did I forget something about your setup? Thanks |
I was having a similar issue when the workspace folder was a symbolic link, and I worked around it by opening the folder directly using its original path. Hope this info helps. |
Just to add another data point. I was hitting an identical issue as mentioned here (no tests discovered but running the discover command from the plugin manually appeared to be working). In my case also, my workspace had been opened through a path that included a symbolic link, and if I instead opened the underlying path directly it worked correctly. @eleanorjboyd
Then you can easily switch between the two folders to reproduce:
(Note: In my case the symbolic link was not the workspace folder itself, but a folder a few levels up in the hierarchy that contained the workspace folder) |
@davidsben is this the folder structure you are suggesting? Not sure where the symlink_test folder should be located in relation to the github_test_discovery_issue folder. Thanks |
I can confirm that in my case (failed discovering the tests), I do have my workspace placed in an external drive whose mnt point is sym-linked to my home directory:
And I am opening my repo in VSCode by navigating to |
And I can further confirm that when I open my repo via the full real path by navigating to /mnt/my_drive/foo/my_repo, I can discover the tests normally. Thanks a lot Azureblade3808 and davidsben ! |
davidsben could chime in on this. @eleanorjboyd I believe what you want to do is to make a symlink of the entire directory, or put the entire directory inside a directory whose path contains a node that is a symlink. In your screenshot above, you only made symlink of the python module. An example sequence of commands to setup the test structure
|
Oh my god this was totally it. Thank you @Jerry-Ma @Azureblade3808 @davidsben |
For completeness I created a new version of the test case that includes a symlinked directory in the right place. updated_github_test_discovery_issue.tar.gz You still need to create a venv and install pytest into the
|
Thank you everyone for your responses and help in figuring out this issue! Closing as it seems the issue is resolved but please let me know if more conversation is needed. Thanks! |
Hi @eleanorjboyd, in what sense is the issue resolved. Does vscode Python now support properly resolving symlinks? |
Just to echo @ZacCranko 's sentiment. Has a fix been implemented in the extension? The discussion above was, at best, a workaround to a bug in the extension (and / or vscode). Outside of vscode there is no problem using pytest in the symlink case, it only fails to work when used within the vscode setup. |
This should not be closed, yet. But the fix for this is that we created a |
Consolidating all issues on testing and symlinks to issue #9347. Let me know if you do not think this other issue is representative of the bug you are facing. Thanks! |
Type: Bug
poetry new github_test_discovery_issue
code-insiders github_test_discovery_issue
touch tests/test_foo.py
then add to itsettings.json
(the one generated by vscode by default)test_foo
:test_foo
Extension version: 2023.3.10481011
VS Code version: Code - Insiders 1.76.0-insider (Universal) (96a795cc0b1cd62f9ff66c347637f917c6dde3da, 2023-02-17T22:20:52.580Z)
OS version: Darwin arm64 22.3.0
Modes:
Sandboxed: Yes
Connection to 'ssh-remote+zac-dev' could not be established
Remote OS version: Linux x64 5.13.0-1023-gcp
System Info
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
Connection to 'ssh-remote+zac-dev' could not be established
A/B Experiments
The text was updated successfully, but these errors were encountered: