Repository navigation
Tests discovery failing on symlink folder #20718
Copy link
Copy link
Closed
Labels
area-testinginfo-neededIssue requires more information from posterIssue requires more information from postertriage-neededNeeds assignment to the proper sub-teamNeeds assignment to the proper sub-team
Description
Type: Bug
- Open a remote-ssh connection to a server, on which run
poetry new github_test_discovery_issuecode-insiders github_test_discovery_issue- Create a new file
touch tests/test_foo.pythen add to it
def test_foo():
assert True- Configure vscode to use pytest with the following
settings.json(the one generated by vscode by default)
{
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}- After following the above steps, the test explorer shows only the folder 'tests', but does not discover
test_foo:
- Pytest run from the terminal in this folder succeeds in discovering and running
test_foo
➜ github_test_discovery_issue pytest tests/
====================== 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
plugins: typeguard-2.13.3, anyio-3.6.2
collected 1 item
tests/test_foo.py . [100%]
======================= 1 passed in 0.01s =======================
- Please help. Thanks!
Extension version: 2023.3.10481011
VS Code version: Code - Insiders 1.76.0-insider (Universal) (96a795c, 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
| Item | Value |
|---|---|
| CPUs | Apple M2 (8 x 24) |
| GPU Status | 2d_canvas: enabled 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 |
| Load (avg) | 5, 4, 3 |
| Memory (System) | 16.00GB (0.74GB free) |
| Process Argv | --crash-reporter-id d2f555fd-c740-461a-926d-b30c1004a468 |
| Screen Reader | no |
| VM | 0% |
Connection to 'ssh-remote+zac-dev' could not be established
| Item | Value |
|---|---|
| Remote | SSH: zac-dev |
| OS | Linux x64 5.13.0-1023-gcp |
| CPUs | AMD EPYC 7B12 (240 x 2250) |
| Memory (System) | 400.47GB (394.47GB free) |
| VM | 0% |
A/B Experiments
vsliv695:30137379
vsins829:30139715
vsliv368:30146709
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
pythonvspyl392:30422396
pythontb:30258533
pythonptprofiler:30281269
vshan820:30294714
pythondataviewer:30285072
vscod805cf:30301675
bridge0708:30335490
bridge0723:30353136
cmake_vspar411:30581797
vsaa593cf:30376535
pythonvs932:30404738
cppdebug:30492333
vscaac:30438845
vsclangdf:30492506
c4g48928:30535728
dsvsc012:30540252
pynewext54:30618038
pylantcb52:30590116
pyindex848:30611229
nodejswelcome1:30587009
pyind779:30611226
pythonsymbol12:30651887
2i9eh265:30646982
showlangstatbar:30659908
pythonb192:30661256
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area-testinginfo-neededIssue requires more information from posterIssue requires more information from postertriage-neededNeeds assignment to the proper sub-teamNeeds assignment to the proper sub-team

Activity
eleanorjboyd commentedon Feb 21, 2023
Could you share your configuration for your poetry environment? Thanks
ZacCranko commentedon Feb 21, 2023
Sure, here's the output from
poetry config --list.eleanorjboyd commentedon Feb 22, 2023
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!
ZacCranko commentedon Feb 22, 2023
No problem, it's as follows:
corey-dawson commentedon Feb 23, 2023
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.
using conda with python 3.9.16
Here is a section of my output;
eleanorjboyd commentedon Feb 23, 2023
corey-dawson can you file a separate issue, since you are using conda and not poetry. Thanks!
ZacCranko commentedon Feb 23, 2023
Eleanor Boyd (@eleanorjboyd) Please let me know if there's anything further you need
eleanorjboyd commentedon Feb 23, 2023
Hi Zac Cranko (@ZacCranko), can you please run this from your command line and see if it returns the expected output
discover pytest -- --rootdir . -s --cache-clear tests? If that doesn't work can you try disabling color on the output? Sometimes this interferes with our ability to parse the pytest output.ZacCranko commentedon Feb 23, 2023
Looks like
test_foois being discovered with that command. Viz."tests": [{"id": "./tests/test_foo.py::test_foo"...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.
corey-dawson commentedon Feb 24, 2023
will do
eleanorjboyd commentedon Feb 27, 2023
Zac Cranko (@ZacCranko), no need to append the run_adapter prefix can you try it like this
python -m pytest --rootdir . -s --cache-clear. Secondly I am not sure the exact setting but feel free to ask the poetry team here if you can't find it: https://github.com/python-poetry/poetry.ZacCranko commentedon Feb 27, 2023
I needed the
run_adapterprefix for thediscovercommand indiscover pytest -- --rootdir . -s --cache-clear teststo do something.The output of
poetry run python -m pytest --rootdir . -s --cache-clearis as follows:17 remaining items
eleanorjboyd commentedon Apr 10, 2023
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!
[-]Tests not discovered[/-][+]Tests discovery failing on symlink folder[/+]ZacCranko commentedon Apr 10, 2023
Hi Eleanor Boyd (@eleanorjboyd), in what sense is the issue resolved. Does vscode Python now support properly resolving symlinks?
davidsben commentedon Apr 17, 2023
Just to echo Zac Cranko (@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.
karthiknadig commentedon Apr 17, 2023
This should not be closed, yet. But the fix for this is that we created a
pytestplugin to detectpytesttests via this PR here #20631 . Which should be able to detect these, but we still need to verify that this case is handled by it.eleanorjboyd commentedon Jul 11, 2023
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!