Skip to content
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

symlink: Pytest immediately finishes without running #22518

Closed
slochower opened this issue Nov 22, 2023 · 23 comments
Closed

symlink: Pytest immediately finishes without running #22518

slochower opened this issue Nov 22, 2023 · 23 comments
Assignees
Labels
area-testing bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster

Comments

@slochower
Copy link

Type: Bug

Behaviour

Expected vs. Actual

Actual: Tests are discovered in the GUI, but running any test immediately shows "Finished running tests!" in the Test Results pane, without running the test.

Expected: Clicking the arrow next to a test (or all tests) runs the test.

Steps to reproduce:

  1. Launch workspace.
  2. Navigate to the TESTING pane.
  3. Try to run any/all tests.

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 3.10.12
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Poetry
  • Value of the python.languageServer setting: Default
Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

(Some names scrambled...)

2023-11-22 11:31:58.429 [info] Experiment 'pythonREPLSmartSend' is active
2023-11-22 11:31:58.429 [info] Experiment 'pythonPromptNewFormatterExt' is active
2023-11-22 11:31:58.430 [info] Experiment 'pythonPromptNewToolsExt' is active
2023-11-22 11:31:58.430 [info] Experiment 'pythonRecommendTensorboardExtcf' is active
2023-11-22 11:31:58.430 [info] Experiment 'pythonTestAdapter' is active
2023-11-22 11:31:58.430 [info] Default formatter is set to charliermarsh.ruff for workspace /Users/slochowe/projects/vx-xxx
2023-11-22 11:31:58.430 [info] Running installed packages checker:  /Users/slochowe/projects/vx-xxx/.venv/bin/python /Users/slochowe/.vscode/extensions/ms-python.python-2023.20.0/pythonFiles/installed_check.py /Users/slochowe/projects/vx-xxx/pyproject.toml
2023-11-22 11:31:58.430 [info] > ./.venv/bin/python ~/.vscode/extensions/ms-python.python-2023.20.0/pythonFiles/installed_check.py ./pyproject.toml
2023-11-22 11:31:58.430 [info] Test server listening.
2023-11-22 11:31:58.430 [info] Python interpreter path: ./.venv/bin/python
2023-11-22 11:32:00.920 [info] Starting Pylance language server.
2023-11-22 11:32:36.032 [info] Discover tests for workspace name: vx-xxx - uri: /Users/slochowe/projects/vx-xxx
2023-11-22 11:32:36.033 [info] Running discovery for pytest using the new test adapter.
2023-11-22 11:32:36.033 [info] All environment variables set for pytest discovery: {"SQLALCHEMY_SILENCE_UBER_WARNING":"1","SCHRODINGER":"/opt/schrodinger/suites2022-3/","BROWSER":"open","COMMAND_MODE":"unix2003","CONDA_DEFAULT_ENV":"base","CONDA_EXE":"/opt/anaconda3/bin/conda","CONDA_PREFIX":"/opt/anaconda3","CONDA_PROMPT_MODIFIER":"(base) ","CONDA_PYTHON_EXE":"/opt/anaconda3/bin/python","CONDA_SHLVL":"1","DISPLAY":"/private/tmp/com.apple.launchd.Q3tHYQNAHa/org.xquartz:0","EDITOR":"nano","GREP_COLOR":"37;45","GREP_COLORS":"mt=37;45","HOME":"/Users/slochowe","JAVA_HOME":"/Library/Java/JavaVirtualMachines/jdk-18.0.2.jdk","LANG":"en_US.UTF-8","LESS":"-F -g -i -M -R -S -w -X -z-4","LESS_TERMCAP_mb":"\u001b[01;31m","LESS_TERMCAP_md":"\u001b[01;31m","LESS_TERMCAP_me":"\u001b[0m","LESS_TERMCAP_se":"\u001b[0m","LESS_TERMCAP_so":"\u001b[00;47;30m","LESS_TERMCAP_ue":"\u001b[0m","LESS_TERMCAP_us":"\u001b[01;32m","LOGNAME":"slochowe","LSCOLORS":"exfxcxdxbxGxDxabagacad","LS_COLORS":"di=34:ln=35:so=32:pi=33:ex=31:bd=36;01:cd=33;01:su=31;40;07:sg=36;40;07:tw=32;40;07:ow=33;40;07:","MallocNanoZone":"0","OLDPWD":"/","ORIGINAL_XDG_CURRENT_DESKTOP":"undefined","PAGER":"less","PWD":"/","SHELL":"/bin/zsh","SHLVL":"0","SSH_AUTH_SOCK":"/private/tmp/com.apple.launchd.KfeUvKK69V/Listeners","TMPDIR":"/var/folders/0k/wn1cythd0_s0h7_zc0j88r_00001cx/T/","USER":"slochowe","VISUAL":"nano","VSCODE_AMD_ENTRYPOINT":"vs/workbench/api/node/extensionHostProcess","VSCODE_CODE_CACHE_PATH":"/Users/slochowe/Library/Application Support/Code/CachedData/2b35e1e6d88f1ce073683991d1eff5284a32690f","VSCODE_CRASH_REPORTER_PROCESS_TYPE":"extensionHost","VSCODE_CWD":"/","VSCODE_HANDLES_UNCAUGHT_ERRORS":"true","VSCODE_IPC_HOOK":"/Users/slochowe/Library/Application Support/Code/1.84-main.sock","VSCODE_NLS_CONFIG":"{\"locale\":\"en-us\",\"osLocale\":\"en-us\",\"availableLanguages\":{},\"_languagePackSupport\":true}","VSCODE_PID":"79124","XPC_FLAGS":"0x0","XPC_SERVICE_NAME":"application.com.microsoft.VSCode.129823046.129823052","_":"/Applications/Visual Studio Code.app/Contents/MacOS/Electron","__CFBundleIdentifier":"com.microsoft.VSCode","__CF_USER_TEXT_ENCODING":"0x59D:0x0:0x0","ELECTRON_RUN_AS_NODE":"1","VSCODE_L10N_BUNDLE_LOCATION":"","PATH":"/Applications/VIDA 4.3.0.4.app/Contents/MacOS/bin:/Applications/VIDA 4.3.0.4.app/Contents/MacOS/bin:/Applications/VIDA 4.3.0.4.app/Contents/MacOS/bin:/Applications/VIDA 4.3.0.4.app/Contents/MacOS/bin:/Users/slochowe/.local/bin/:/opt/anaconda3/bin:/opt/anaconda3/condabin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/usr/local/laps:/opt/X11/bin:/Applications/quarto/bin:/Users/slochowe/.fzf/bin","PYTHONPATH":"/Users/slochowe/.vscode/extensions/ms-python.python-2023.20.0/pythonFiles","TEST_UUID":"4bcd3756-6e9a-42b9-912c-ceed7fd4f4c6","TEST_PORT":"50592"}
2023-11-22 11:32:36.055 [info] > . ./.venv/bin/activate && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python ~/.vscode/extensions/ms-python.python-2023.20.0/pythonFiles/printEnvVariables.py
2023-11-22 11:32:36.055 [info] shell: bash
2023-11-22 11:32:36.120 [info] > ./.venv/bin/python -m pytest -p vscode_pytest --collect-only tests
2023-11-22 11:32:36.120 [info] cwd: .
2023-11-22 11:32:36.534 [info] �[1m============================= test session starts ==============================�[0m
platform darwin -- Python 3.10.12, pytest-7.2.2, pluggy-1.3.0

2023-11-22 11:32:36.540 [info] rootdir: /Volumes/OWC/projects/vx-xxx, configfile: pyproject.toml
plugins: html-3.2.0, metadata-3.0.0, dependency-0.5.1, cov-4.0.0

2023-11-22 11:32:42.235 [info] collected 18 items

<Module tests/test_cli.py>
2023-11-22 11:32:42.235 [info] 
  <Function test_1>
  <Function test_2>
  <Function test_3>
<Module tests/test_fetch.py>
  <Function test_x>
  <Function test_y>
  <Function test_z>
<Module tests/test_import.py>
  <Function test_1>
  <Function test_2>
  <Function test_3>
  <Function test_4>
<Module tests/test_alpha.py>
  <Function test_a>
  <Function test_b>
<Module tests/test_beta.py>
  <Function test_1>
<Module tests/test_gamma.py>
  <Function test_a>
<Module tests/test_delta.py>
  <Function test_x>
  <Function test_y>
  <Function test_z>
  <Function test_q>

2023-11-22 11:32:42.246 [info] Test server connected to a client.
2023-11-22 11:32:42.253 [info] ResultResolver EOT received for discovery.
2023-11-22 11:32:42.253 [info] 
- generated xml file: /Volumes/OWC/projects/vx-xxx/test-results/unit-tests-results.xml -
- generated html file: file:///Volumes/OWC/projects/vx-xxx/test-results/unit-tests-results.html -
�[32m========================= �[32m18 tests collected�[0m�[32m in 5.71s�[0m�[32m ==========================�[0m

2023-11-22 11:32:42.633 [info] Disposing data receiver for /Users/slochowe/projects/vx-xxx and deleting UUID; pytest discovery.
2023-11-22 11:37:17.149 [info] > conda info --json

User Settings


languageServer: "Pylance"

testing
• pytestArgs: "<placeholder>"
• pytestEnabled: true

experiments
• optInto: ["pythonREPLSmartSend"]

Extension version: 2023.20.0
VS Code version: Code 1.84.1 (2b35e1e6d88f1ce073683991d1eff5284a32690f, 2023-11-06T12:37:18.666Z)
OS version: Darwin x64 21.6.0
Modes:

System Info
Item Value
CPUs Intel(R) Xeon(R) W-3223 CPU @ 3.50GHz (16 x 3500)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) 7, 7, 6
Memory (System) 48.00GB (2.72GB free)
Process Argv --crash-reporter-id cb48efa2-f1ba-49ea-ab73-be7b0e1a36ce
Screen Reader no
VM 0%
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
vserr242:30382549
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vsdfh931:30280409
vshan820:30294714
vstes263:30335439
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593:30376534
pythonvs932:30410667
py29gd2263:30880072
a247i228:30880122
vsclangdc:30486549
c4g48928:30535728
dsvsc012:30540252
pynewext54:30695312
azure-dev_surveyone:30548225
2e4cg342:30602488
89544117:30613380
vscrp:30673768
2i9eh265:30646982
showlangstatbar:30737416
pythonfmttext:30731395
fixshowwlkth:30771522
showindicator:30805244
pythongtdpath:30769146
i26e3531:30792625
welcomedialogc:30887144
pythonnosmt12:30797651
pythonidxpt:30866567
pythonnoceb:30805159
synctok:30869157
dsvsc013:30795093
dsvsc014:30804076
dsvsc015:30845448
pythontestfixt:30871694
pythonregdiag2:30871582
pyreplss1:30897532
pythonmypyd1:30879173
pythoncet0:30885854
2e7ec940:30885897
pythontbext0:30879054
accentitlementsc:30887149
dsvsc016cf:30886111
dsvsc017cf:30886113
dsvsc018:30886114
aa_t_chat:30882232

@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Nov 22, 2023
@eleanorjboyd
Copy link
Member

Hi! Could you check in your "python test logs" and send those? Might be something happening on the python side which shows up there. Also to confirm these are all the logs right after you click the run button? I am seeing no logs related to an attempted run since after clicking the "play" button there are usually additional logs printed right away.

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Nov 27, 2023
@slochower
Copy link
Author

Hi, this is all that I see in Python Test Logs:

�[1m============================= test session starts ==============================�[0m
platform darwin -- Python 3.10.12, pytest-7.2.2, pluggy-1.3.0
rootdir: /Volumes/OWC/projects/vx-xxx, configfile: pyproject.toml
plugins: anyio-4.0.0, html-3.2.0, metadata-3.0.0, dependency-0.5.1, cov-4.0.0, xdist-3.5.0
collected 18 items

<Module tests/test_cli.py>
  [...all tests listed here...]
  <Function test_extract>

- generated xml file: /Volumes/OWC/projects/vx-xxx/test-results/unit-tests-results.xml -
- generated html file: file:///Volumes/OWC/projects/vx-xxx/test-results/unit-tests-results.html -
�[32m========================= �[32m18 tests collected�[0m�[32m in 7.12s�[0m�[32m ==========================�[0m
Starting now, all test run output will be sent to the Test Result panel, while test discovery output will be sent to the "Python" output channel instead of the "Python Test Log" channel. The "Python Test Log" channel will be deprecated within the next month. See https://github.com/microsoft/vscode-python/wiki/New-Method-for-Output-Handling-in-Python-Testing for details.

This is right after I click the play button on the sidebar under Testing, yep.

Nothing new shows up in the Python logs, here is the last snippet of those.


2023-11-27 11:06:29.909 [info] Test server connected to a client.
2023-11-27 11:06:29.913 [info] ResultResolver EOT received for discovery.
2023-11-27 11:06:29.913 [info] 
- generated xml file: /Volumes/OWC/projects/vx-xxx/test-results/unit-tests-results.xml -
- generated html file: file:///Volumes/OWC/projects/vx-xxx/test-results/unit-tests-results.html -
�[32m========================= �[32m18 tests collected�[0m�[32m in 7.12s�[0m�[32m ==========================�[0m

2023-11-27 11:06:30.277 [info] Disposing data receiver for /Users/slochowe/projects/vx-xxx and deleting UUID; pytest discovery.

It's worth noting 1) this is local, not SSH 2) Running regular old pytest on the command line works as expected 3) I tried toggling the pythonTestAdapter in settings.json.

@github-actions github-actions bot removed the info-needed Issue requires more information from poster label Nov 27, 2023
@eleanorjboyd
Copy link
Member

Could you try running this again but this time without html-3.2.0 plugin?

Secondly do you see anything in your logs which say "data received from python server:"? It is a debug level so maybe setting your log level via the command palette "developer: set log level" to debug or trace could help produce these logs which give a better idea of what could be happening.

@slochower
Copy link
Author

slochower commented Nov 27, 2023

Actually, after a delay (7 minutes) I do see these messages in the Python log (first message in the snippet below is the last message from my last reply):

2023-11-27 11:06:30.277 [info] Disposing data receiver for /Users/slochowe/projects/vx-xxx and deleting UUID; pytest discovery.
2023-11-27 11:13:15.869 [info] Discover tests for workspace name: undefined - uri: /Volumes/OWC/projects/vx-xxx/src/vx_xxx/tasks/import_.py
2023-11-27 11:13:15.869 [info] Running discovery for pytest using the new test adapter.
2023-11-27 11:13:15.869 [error] Unable to find workspace for given file
2023-11-27 11:13:21.968 [info] Discover tests for workspace name: undefined - uri: /Volumes/OWC/projects/vx-xxx/src/vx_xxx/tasks/import_.py
2023-11-27 11:13:21.968 [info] Running discovery for pytest using the new test adapter.
2023-11-27 11:13:21.968 [error] Unable to find workspace for given file
2023-11-27 11:13:24.016 [info] Discover tests for workspace name: undefined - uri: /Volumes/OWC/projects/vx-xxx/src/vx_xxx/tasks/import_.py
2023-11-27 11:13:24.016 [info] Running discovery for pytest using the new test adapter.
2023-11-27 11:13:24.016 [error] Unable to find workspace for given file
2023-11-27 11:13:26.016 [info] Discover tests for workspace name: undefined - uri: /Volumes/OWC/projects/vx-xxx/src/vx_xxx/tasks/import_.py
2023-11-27 11:13:26.016 [info] Running discovery for pytest using the new test adapter.
2023-11-27 11:13:26.016 [error] Unable to find workspace for given file
2023-11-27 11:13:28.584 [info] Discover tests for workspace name: undefined - uri: /Volumes/OWC/projects/vx-xxx/src/vx_xxx/tasks/import_.py
2023-11-27 11:13:28.584 [info] Running discovery for pytest using the new test adapter.
2023-11-27 11:13:28.585 [error] Unable to find workspace for given file
2023-11-27 11:13:46.964 [info] Discover tests for workspace name: undefined - uri: /Volumes/OWC/projects/vx-xxx/src/vx_xxx/tasks/import_.py
2023-11-27 11:13:46.964 [info] Running discovery for pytest using the new test adapter.
2023-11-27 11:13:46.964 [error] Unable to find workspace for given file
2023-11-27 11:13:54.618 [info] Discover tests for workspace name: undefined - uri: /Volumes/OWC/projects/vx-xxx/src/vx_xxx/tasks/import_.py
2023-11-27 11:13:54.618 [info] Running discovery for pytest using the new test adapter.
2023-11-27 11:13:54.619 [error] Unable to find workspace for given file
2023-11-27 11:14:00.322 [info] Discover tests for workspace name: undefined - uri: /Volumes/OWC/projects/vx-xxx/src/vx_xxx/tasks/import_.py
2023-11-27 11:14:00.322 [info] Running discovery for pytest using the new test adapter.
2023-11-27 11:14:00.322 [error] Unable to find workspace for given file
2023-11-27 11:14:08.887 [info] Discover tests for workspace name: undefined - uri: /Volumes/OWC/projects/vx-xxx/src/vx_xxx/tasks/import_.py
2023-11-27 11:14:08.887 [info] Running discovery for pytest using the new test adapter.
2023-11-27 11:14:08.887 [error] Unable to find workspace for given file
2023-11-27 11:14:20.873 [info] Discover tests for workspace name: undefined - uri: /Volumes/OWC/projects/vx-xxx/src/vx_xxx/tasks/import_.py
2023-11-27 11:14:20.873 [info] Running discovery for pytest using the new test adapter.
2023-11-27 11:14:20.873 [error] Unable to find workspace for given file
2023-11-27 11:14:30.672 [info] Discover tests for workspace name: undefined - uri: /Volumes/OWC/projects/vx-xxx/src/vx_xxx/tasks/import_.py
2023-11-27 11:14:30.672 [info] Running discovery for pytest using the new test adapter.
2023-11-27 11:14:30.672 [error] Unable to find workspace for given file
2023-11-27 11:14:44.542 [info] Discover tests for workspace name: undefined - uri: /Volumes/OWC/projects/vx-xxx/src/vx_xxx/tasks/import_.py
2023-11-27 11:14:44.542 [info] Running discovery for pytest using the new test adapter.
2023-11-27 11:14:44.542 [error] Unable to find workspace for given file
2023-11-27 11:14:49.948 [info] Discover tests for workspace name: undefined - uri: /Volumes/OWC/projects/vx-xxx/src/vx_xxx/tasks/import_.py
2023-11-27 11:14:49.948 [info] Running discovery for pytest using the new test adapter.

Is this helpful?

You see two paths here: /Volumes/OWC/projects/... and /Users/slochowe/projects/... the former is symlinked to the latter. Is the issue a failure to follow the symlink?

  • Uninstalling pytest-html had no effect.
  • I do not see "data received..." anywhere. I went to the DEBUG log level and I see a bunch of "Found cached env...", "Resolved...", and "Cached data exists..."

Edit: I do see data received:

{"cwd": "/Volumes/OWC/projects/vx-xxx", "status": "success", "tests": {"name": "vx-xxx", "path": "/Volumes/OWC/projects/vx-xxx", "type_": "folder", "children": [{"name": "tests", "path": "/Volumes/OWC/projects/vx-xxx/tests", "type_": "folder", "id_": "/Volumes/OWC/projects/vx-xxx/tests", "children": [{"name": "test_cli.py", "path": "/Volumes/OWC/projects/vx-xxx/tests/test_cli.py", "type_": "file", "id_": "/Volumes/OWC/projects/vx-xxx/tests/test_cli.py", "children": [..."id_": "/Volumes/OWC/projects/vx-xxx"}, "error": []}Content-Length: 42
Content-Type: application/json
Request-uuid: 810db473-f7c5-45d2-b960-9039579a3239

@github-actions github-actions bot added info-needed Issue requires more information from poster and removed info-needed Issue requires more information from poster labels Nov 27, 2023
@eleanorjboyd
Copy link
Member

hm yes we have been having ongoing issues with symlinks. Does this look like it could be similar? #22018

secondly do you see the following as well in your logs (below is the example with my own logs of the necessary steps it prints after getting the data)? It seems your data is returning correctly from the pytest process but is not being parsed and displayed correctly

2023-11-27 15:31:40.979 [debug] Firing data received event,  {"command_type": "execution", "eot": true}
2023-11-27 15:31:40.979 [info] ResultResolver EOT received for execution.
2023-11-27 15:31:40.991 [info] Client disconnected
2023-11-27 15:31:40.997 [debug] Test run finished, subprocess closed.
2023-11-27 15:31:40.997 [debug] deferredTill EOT resolved
2023-11-27 15:31:40.998 [info] Disposing data receiver for /Users/eleanorboyd/testingFiles/inc_dec_example and deleting UUID; pytest execution.

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Nov 27, 2023
@slochower
Copy link
Author

I do see something like your logs in mine:

2023-11-27 15:37:29.578 [info] ResultResolver EOT received for discovery.
2023-11-27 15:37:29.578 [info] 
========================= 18 tests collected in 8.44s ==========================

2023-11-27 15:37:29.780 [debug] Testing: Resolving item /Volumes/OWC/projects/vx-xxx
2023-11-27 15:37:29.781 [debug] Testing: Resolving item /Volumes/OWC/projects/vx-xxx/tests
2023-11-27 15:37:29.781 [debug] Testing: Resolving item /Volumes/OWC/projects/vx-xxx/tests/test_asdfasldfasdklfjasdf.py
2023-11-27 15:37:29.956 [debug] deferredTill EOT resolved
2023-11-27 15:37:29.957 [info] Disposing data receiver for /Users/slochowe/projects/vx-xxx and deleting UUID; pytest discovery.

Okay, yes this is somehow related to the symlink. I opened from the non-symlinked (i.e., source) location, ran a test, and it worked. I then opened again from the symlinked version and testing is working. Perhaps something with caching an unresolved path?

@github-actions github-actions bot removed the info-needed Issue requires more information from poster label Nov 27, 2023
@eleanorjboyd
Copy link
Member

hm thats an interesting theory about the unresolved path. I will work on this soon as my primary blocker is I have not been able to repro locally. Does your setup align with that of the most recent poster on that thread? Where the symlinks have the same root and they are both locally on the same machine?

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Nov 27, 2023
@slochower
Copy link
Author

I think my setup mostly aligns with that thread, yes. When I open the project from the two different directories, I even see two different entries under "Recent" on the "Welcome" page. If I open from the symlink on the Welcome page, tests are not working ("Finished running tests!" shows up immediately). If I open from the source on the Welcome page, then tests run.

@github-actions github-actions bot removed the info-needed Issue requires more information from poster label Nov 28, 2023
@eleanorjboyd
Copy link
Member

Hello! I have put together a detailed problem report and proposed solution for symlinks. Please check it out here and contribute any thoughts you may have: #22658

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Dec 18, 2023
Copy link

Because we have not heard back with the information we requested, we are closing this issue for now. If you are able to provide the info later on, then we will be happy to re-open this issue to pick up where we left off.

Happy Coding!

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 18, 2024
@eleanorjboyd eleanorjboyd reopened this Jan 18, 2024
@nicc777
Copy link

nicc777 commented Jan 21, 2024

I am having a similar issue. You can check this tagged commit.

A screenshot is available at https://imgur.com/gallery/qGgkyRI

No matter how many times I run the unit tests, nothing happens

  • VSCode Version: 1.85.2
  • I am running on Ubuntu 22.04.3 LTS
  • Python version: 3.10.12

Running unit tests manually from the command line works:

python3 -m unittest discover -s tests
sys.path=['/media/nicc777/data/nicc777/git/Personal/GitHub/poc_pytaskflow/tests', '/media/nicc777/data/nicc777/git/Personal/GitHub/poc_pytaskflow', '/usr/lib/python310.zip', '/usr/lib/python3.10', '/usr/lib/python3.10/lib-dynload', '/media/nicc777/data/nicc777/git/Personal/GitHub/poc_pytaskflow/venv/lib/python3.10/site-packages', '/media/nicc777/data/nicc777/git/Personal/GitHub/poc_pytaskflow/tests/../src']
Current Working Path: /media/nicc777/data/nicc777/git/Personal/GitHub/poc_pytaskflow
--------------------------------------------------------------------------------
df={'a': 'AA', 'bb': {'c': 123, 'dd': True}, 'ccc': [1, 2, 3]}
.
----------------------------------------------------------------------
Ran 1 test in 0.000s

OK

Output Python panel:

2024-01-21 17:17:00.029 [info] Experiment 'pythonRecommendTensorboardExt' is active
2024-01-21 17:17:00.029 [info] Experiment 'pythonREPLSmartSend' is active
2024-01-21 17:17:00.029 [info] Experiment 'pythonTerminalEnvVarActivationcf' is active
2024-01-21 17:17:00.029 [info] Experiment 'pythonTestAdapter' is active
2024-01-21 17:17:00.029 [info] Default formatter is set to null for workspace /home/nicc777/git/Personal/GitHub/poc_pytaskflow
2024-01-21 17:17:00.029 [info] Test server listening.
2024-01-21 17:17:00.029 [info] Python interpreter path: ./venv/bin/python
2024-01-21 17:17:02.143 [info] Starting Pylance language server.
2024-01-21 17:17:02.598 [info] Discover tests for workspace name: poc_pytaskflow - uri: /home/nicc777/git/Personal/GitHub/poc_pytaskflow
2024-01-21 17:17:02.598 [info] Running discovery for unittest using the new test adapter.
2024-01-21 17:17:02.659 [info] > . ./venv/bin/activate && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python ~/.vscode/extensions/ms-python.python-2023.22.1/pythonFiles/printEnvVariables.py
2024-01-21 17:17:02.659 [info] shell: bash
2024-01-21 17:17:02.706 [info] Discovering unittest tests for workspace /home/nicc777/git/Personal/GitHub/poc_pytaskflow with arguments: /home/nicc777/.vscode/extensions/ms-python.python-2023.22.1/pythonFiles/unittestadapter/discovery.py,--udiscovery,-v,-s,./tests,-p,test*.py

2024-01-21 17:17:02.706 [info] > ./venv/bin/python ~/.vscode/extensions/ms-python.python-2023.22.1/pythonFiles/unittestadapter/discovery.py --udiscovery -v -s ./tests -p test*.py
2024-01-21 17:17:02.706 [info] cwd: .
2024-01-21 17:17:02.745 [info] sys.path=['/media/nicc777/data/nicc777/git/Personal/GitHub/poc_pytaskflow/tests', '.', '/home/nicc777/.vscode/extensions/ms-python.python-2023.22.1/pythonFiles/lib/python', '/home/nicc777/.vscode/extensions/ms-python.python-2023.22.1/pythonFiles/unittestadapter', '/home/nicc777/git/Personal/GitHub/poc_pytaskflow', '/usr/lib/python310.zip', '/usr/lib/python3.10', '/usr/lib/python3.10/lib-dynload', '/home/nicc777/git/Personal/GitHub/poc_pytaskflow/venv/lib/python3.10/site-packages', '/home/nicc777/.vscode/extensions/ms-python.python-2023.22.1/pythonFiles', '/home/nicc777/.vscode/extensions/ms-python.python-2023.22.1/pythonFiles', '/home/nicc777/.vscode/extensions/ms-python.python-2023.22.1/pythonFiles/lib/python', '/media/nicc777/data/nicc777/git/Personal/GitHub/poc_pytaskflow/tests/../src']

2024-01-21 17:17:02.746 [info] Current Working Path: /media/nicc777/data/nicc777/git/Personal/GitHub/poc_pytaskflow

2024-01-21 17:17:02.749 [info] Test server connected to a client.
2024-01-21 17:17:02.749 [info] Test server connected to a client.
2024-01-21 17:17:02.752 [info] ResultResolver EOT received for discovery.
2024-01-21 17:18:02.618 [info] Send text to terminal: source /home/nicc777/git/Personal/GitHub/poc_pytaskflow/venv/bin/activate
2024-01-21 17:18:34.654 [info] > conda info --json
2024-01-21 17:18:44.239 [info] CreateEnv Trigger - Skipping for /home/nicc777/git/Personal/GitHub/poc_pytaskflow/tests/test_models_task.py
2024-01-21 17:18:44.289 [info] Send text to terminal: source /home/nicc777/git/Personal/GitHub/poc_pytaskflow/venv/bin/activate
2024-01-21 17:18:44.790 [info] Send text to terminal: /home/nicc777/git/Personal/GitHub/poc_pytaskflow/venv/bin/python /home/nicc777/git/Personal/GitHub/poc_pytaskflow/tests/test_models_task.py
2024-01-21 17:20:55.328 [info] Discover tests for workspace name: undefined - uri: /media/nicc777/data/nicc777/git/Personal/GitHub/poc_pytaskflow/tests/test_models_task.py
2024-01-21 17:20:55.328 [info] Running discovery for unittest using the new test adapter.
2024-01-21 17:20:55.328 [error] Unable to find workspace for given file

Output Python Language Server panel:

2024-01-21 17:17:01.514 [info] (Client) Pylance async client (2023.12.1) started with python extension (2023.22.1)
2024-01-21 17:17:02.122 [info] [Info  - 5:17:02 PM] (792766) Pylance language server 2023.12.1 (pyright a78e2b10) starting
2024-01-21 17:17:02.124 [info] [Info  - 5:17:02 PM] (792766) Server root directory: /home/nicc777/.vscode/extensions/ms-python.vscode-pylance-2023.12.1/dist
2024-01-21 17:17:02.128 [info] [Info  - 5:17:02 PM] (792766) Starting service instance "poc_pytaskflow"
2024-01-21 17:17:02.163 [info] [Info  - 5:17:02 PM] (792766) Setting pythonPath for service "poc_pytaskflow": "/home/nicc777/git/Personal/GitHub/poc_pytaskflow/venv/bin/python"
2024-01-21 17:17:02.163 [info] [Info  - 5:17:02 PM] (792766) Setting environmentName for service "poc_pytaskflow": "3.10.12 (venv venv)"
2024-01-21 17:17:02.167 [info] [Info  - 5:17:02 PM] (792766) Loading pyproject.toml file at /home/nicc777/git/Personal/GitHub/poc_pytaskflow/pyproject.toml
2024-01-21 17:17:02.169 [info] [Info  - 5:17:02 PM] (792766) Pyproject file "/home/nicc777/git/Personal/GitHub/poc_pytaskflow/pyproject.toml" has no "[tool.pyright]" section.
2024-01-21 17:17:02.195 [info] [Info  - 5:17:02 PM] (792766) Assuming Python version 3.10
2024-01-21 17:17:02.243 [info] [Info  - 5:17:02 PM] (792766) Auto-excluding /home/nicc777/git/Personal/GitHub/poc_pytaskflow/venv
2024-01-21 17:17:02.246 [info] [Info  - 5:17:02 PM] (792766) Found 5 source files
2024-01-21 17:18:17.024 [info] [Info  - 5:18:17 PM] (792766) Setting pythonPath for service "poc_pytaskflow": "/home/nicc777/git/Personal/GitHub/poc_pytaskflow/venv/bin/python"
2024-01-21 17:18:17.025 [info] [Info  - 5:18:17 PM] (792766) Setting environmentName for service "poc_pytaskflow": "3.10.12 (venv venv)"
2024-01-21 17:18:17.025 [info] [Info  - 5:18:17 PM] (792766) Loading pyproject.toml file at /home/nicc777/git/Personal/GitHub/poc_pytaskflow/pyproject.toml
2024-01-21 17:18:17.026 [info] [Info  - 5:18:17 PM] (792766) Pyproject file "/home/nicc777/git/Personal/GitHub/poc_pytaskflow/pyproject.toml" has no "[tool.pyright]" section.
2024-01-21 17:18:17.073 [info] [Info  - 5:18:17 PM] (792766) Assuming Python version 3.10
2024-01-21 17:18:17.106 [info] [Info  - 5:18:17 PM] (792766) Auto-excluding /home/nicc777/git/Personal/GitHub/poc_pytaskflow/venv
2024-01-21 17:18:17.106 [info] [Info  - 5:18:17 PM] (792766) Found 5 source files

Output Python Test Log panel:

python /home/nicc777/.vscode/extensions/ms-python.python-2023.22.1/pythonFiles/unittestadapter/discovery.py --udiscovery -v -s ./tests -p test*.py
sys.path=['/media/nicc777/data/nicc777/git/Personal/GitHub/poc_pytaskflow/tests', '.', '/home/nicc777/.vscode/extensions/ms-python.python-2023.22.1/pythonFiles/lib/python', '/home/nicc777/.vscode/extensions/ms-python.python-2023.22.1/pythonFiles/unittestadapter', '/home/nicc777/git/Personal/GitHub/poc_pytaskflow', '/usr/lib/python310.zip', '/usr/lib/python3.10', '/usr/lib/python3.10/lib-dynload', '/home/nicc777/git/Personal/GitHub/poc_pytaskflow/venv/lib/python3.10/site-packages', '/home/nicc777/.vscode/extensions/ms-python.python-2023.22.1/pythonFiles', '/home/nicc777/.vscode/extensions/ms-python.python-2023.22.1/pythonFiles', '/home/nicc777/.vscode/extensions/ms-python.python-2023.22.1/pythonFiles/lib/python', '/media/nicc777/data/nicc777/git/Personal/GitHub/poc_pytaskflow/tests/../src']
Current Working Path: /media/nicc777/data/nicc777/git/Personal/GitHub/poc_pytaskflow
Starting now, all test run output will be sent to the Test Result panel, while test discovery output will be sent to the "Python" output channel instead of the "Python Test Log" channel. The "Python Test Log" channel will be deprecated within the next month. See https://github.com/microsoft/vscode-python/wiki/New-Method-for-Output-Handling-in-Python-Testing for details.

Let me know if you need anything else.

@nicc777
Copy link

nicc777 commented Jan 22, 2024

UPDATE: I resolved my problem after a lot more reading that indicated that symlinks may be a problem.

So, I have 2x SSD's. In my home directory (/home/nicc777) I have symlinked a couple of directories to the second SSD:

$ ls -lahrt | grep git
lrwxrwxrwx  1 nicc777 nicc777   31 Sep  2  2022 git -> /media/nicc777/data/nicc777/git

Initially I opened the project from the perspective of my home directory. So in VSCode, I navigated to /home/nicc777/git/Personal/GitHub/poc_pytaskflow and this caused the problem above.

Afterwards I opened the project from this directory: /media/nicc777/data/nicc777/git/Personal/GitHub/poc_pytaskflow

Now everything works as it should. Screenshot: https://imgur.com/gallery/hxKMvED

So in my case this problem was symlink related. It seems sometimes VSCode refers to the real path and sometimes to the linked path and this inconsistency causes the problem.

@eleanorjboyd eleanorjboyd changed the title Pytest immediately finishes without running symlink: Pytest immediately finishes without running Jan 25, 2024
@eleanorjboyd
Copy link
Member

The bug was referenced but the symlink issue is know and I will get to it soon! Thanks

@eleanorjboyd eleanorjboyd removed the info-needed Issue requires more information from poster label Jan 25, 2024
@eleanorjboyd eleanorjboyd added bug Issue identified by VS Code Team member as probable bug and removed triage-needed Needs assignment to the proper sub-team labels Jan 25, 2024
@eleanorjboyd
Copy link
Member

Hello! This bug should be fixed and on vscode insiders! The release to vscode stable will be out by the end of the week. Please let me know if you try it on insiders or stable when it comes out and still doesn't work and I can investigate your specific issue further.

@kjohnsen
Copy link

I'm still running into this problem. I'm using Python extension v2024.3.10731011 (pre-release).
It happens when I'm in a symlinked directory somewhere up the line. My file structure is as follows:

scratch-link -> scratch
scratch
└── vscode-tests-bug
    └── tests
        └── test_test.py

All is well if I open scratch/vscode-tests-bug, but not if I open scratch-link/vscode-tests-bug

image

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 3.12.1
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Conda
  • Value of the python.languageServer setting: Pylance
Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

2024-03-13 15:38:00.320 [info] > conda run -n base --no-capture-output python ~/.vscode-server-insiders/extensions/ms-python.python-2024.3.10731011/python_files/get_output_via_markers.py ~/.vscode-server-insiders/extensions/ms-python.python-2024.3.10731011/python_files/printEnvVariables.py
2024-03-13 15:38:00.320 [info] shell: bash
2024-03-13 15:38:00.329 [info] > conda info --json
2024-03-13 15:38:00.329 [info] shell: zsh
2024-03-13 15:38:00.329 [info] Python interpreter path: ~/miniforge3/bin/python
2024-03-13 15:38:01.214 [info] > conda run -n base --no-capture-output python ~/.vscode-server-insiders/extensions/ms-python.python-2024.3.10731011/python_files/get_output_via_markers.py -m pytest -p vscode_pytest --collect-only tests
2024-03-13 15:38:01.214 [info] cwd: .
2024-03-13 15:38:01.711 [info] Discover tests for workspace name: vscode-tests-bug - uri: /home/kyle/scratch-link/vscode-tests-bug
2024-03-13 15:38:01.711 [info] Running discovery for pytest using the new test adapter.
2024-03-13 15:38:01.711 [error] Test discovery already in progress, not starting a new one.
2024-03-13 15:38:01.894 [info] >>>PYTHON-EXEC-OUTPUT

2024-03-13 15:38:01.926 [info] > conda run -n base --no-capture-output python ~/.vscode-server-insiders/extensions/ms-python.python-2024.3.10731011/python_files/get_output_via_markers.py ~/.vscode-server-insiders/extensions/ms-python.python-2024.3.10731011/python_files/printEnvVariables.py
2024-03-13 15:38:01.926 [info] shell: zsh
2024-03-13 15:38:02.086 [info] tests/test_test.py::test_foo

2024-03-13 15:38:02.086 [info] Test server connected to a client.
2024-03-13 15:38:02.087 [info] 
1 test collected in 0.00s
<<<PYTHON-EXEC-OUTPUT

2024-03-13 15:38:02.089 [info] ResultResolver EOT received for discovery.
2024-03-13 15:38:02.154 [info] Disposing data receiver for /home/kyle/scratch-link/vscode-tests-bug and deleting UUID; pytest discovery.
2024-03-13 15:38:02.680 [info] > /bin/python3 ~/.vscode-server-insiders/extensions/ms-python.python-2024.3.10731011/python_files/printEnvVariables.py
2024-03-13 15:38:02.680 [info] shell: zsh
2024-03-13 15:38:03.701 [info] Setting environment variable CONDA_ROOT in collection to /home/kyle/miniforge3 {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2024-03-13 15:38:03.702 [info] Send text to terminal: /bin/python3 /home/kyle/.vscode-server-insiders/extensions/ms-python.python-2024.3.10731011/python_files/printEnvVariablesToFile.py /home/kyle/.vscode-server-insiders/extensions/ms-python.python-2024.3.10731011/python_files/deactivate/zsh/envVars.txt

User Settings


languageServer: "Pylance"

testing
• pytestEnabled: true
• autoTestDiscoverOnSaveEnabled: false

@derDere
Copy link

derDere commented Mar 14, 2024

I'm still running into this problem. I'm using Python extension v2024.3.10731011 (pre-release). It happens when I'm in a symlinked directory somewhere up the line. My file structure is as follows:

scratch-link -> scratch
scratch
└── vscode-tests-bug
    └── tests
        └── test_test.py

All is well if I open scratch/vscode-tests-bug, but not if I open scratch-link/vscode-tests-bug

image

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 3.12.1
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Conda
  • Value of the python.languageServer setting: Pylance

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)
User Settings

I can confirm this issue my vscode has the same behaviour. I am inside my WSL and in my home dir i have a documents symlink linked to a WSL folder inside my windows file system (my documents).

documents -> '/mnt/d/Users/myusername/WSL Home Contents/Documents'

If im inside of that symlink my vscode doesn't load any tests. If I move my workspace into an "normal" WSL folder /home/myusername/workspace It runs the tests normally as intended.

@nicc777
Copy link

nicc777 commented Mar 14, 2024

@derDere - Sounds similar to my case. It should work if you open "/mnt/d/Users/myusername/WSL Home Contents/Documents'" - can you confirm? I have a similar situation on my work laptop (using WSL) but these days I just keep my git repo in WSL and be done with it. You can easily navigate from Windows to that WSL directory if you need to.

@kjohnsen
Copy link

@eleanorjboyd any update on this issue?

@eleanorjboyd
Copy link
Member

Hello, sorry for the delay as I have been working on other areas. I will investigate this soon and get back to you all- thank you for the detailed repro steps!

@eleanorjboyd
Copy link
Member

I have made the following symlink to try and repro your scenario and am able to get tests working:

ln -s /Users/eleanorboyd/testingFiles/v2/symlink_v3 /Users/eleanorboyd/Desktop/symlink_desktop_v3
so /Users/eleanorboyd/Desktop/symlink_desktop_v3 -> /Users/eleanorboyd/testingFiles/v2/symlink_v3

What about my setup do I need to change to see this issue?

@eleanorjboyd eleanorjboyd added the info-needed Issue requires more information from poster label Mar 29, 2024
@kjohnsen
Copy link

kjohnsen commented Apr 3, 2024

I see two differences with my setup that might be relevant:

  1. Are you on WSL?
  2. The workspace folder itself isn't a symlink, but the folder containing the workspace folder. I tried your setup (where the workspace folder is the one symlinked) and the tests work. So this detail is important for sure.

Here is

scratch/vscode-tests-bug  |  scratch-link/vscode-tests-bug  |  testsbug2 -> vscode-tests-bug

image

@eleanorjboyd
Copy link
Member

Can you turn on trace for logs then send me them? I need to see if the symlink is recognized by vscode and if it even hits my edge case I put in to resolve it. I have a mac so I am having trouble reproing since it seems vscode resolves paths. What I am seeing is I can't to open the symlink sub-folder without vscode resolving it. I can also speak with my colleague who works on that specifically.

The logs should include this trace log if it recognizes it as a symlink and adjust accordingly "The cwd is a symbolic link, adding '--rootdir' to pytestArgs only if it doesn't already exist." so you can see that during discovery.

Also is both discovery and execution breaking or just one of those which does work? And to confirm you are using pytest right?

Sorry for all the questions and I appreciate your help!

@kjohnsen
Copy link

I just updated and ran again and it's fixed!

I assume you mean trace for Python logging? I do see that:
image

I see a plugin warning on execution:
image

And the error was just on execution, not discovery. Yes, using pytest.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-testing bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

5 participants