vscode-python: Tests discovery failing on symlink folder

Type: Bug

  1. Open a remote-ssh connection to a server, on which run
  2. poetry new github_test_discovery_issue
  3. code-insiders github_test_discovery_issue
  4. Create a new file touch tests/test_foo.py then add to it
def test_foo():
    assert True
  1. 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:
Screenshot 2023-02-20 at 9 26 07 am
  • 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) (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
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

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 34 (12 by maintainers)

Most upvoted comments

This should not be closed, yet. But the fix for this is that we created a pytest plugin to detect pytest tests via this PR here https://github.com/microsoft/vscode-python/pull/20631 . Which should be able to detect these, but we still need to verify that this case is handled by it.

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.