vscode-python: VSCode cannot detect pytest unit tests, even pytest has been installed, error comes from inside .vscode-serve folder, behind company's proxy

Issue Type: Bug

Behaviour

Expected vs. Actual

Expect a list of unit tests, actually got the error message: Error discovering pytest tests (see Output > Python):

Here is the error image

One strange thing I notice in the above screenshot is: it always has a “d” inside the search bar under Testing even I closed and re-open VSCode, you can see it from the screenshot above.

Here is the evidence that I have installed the pytest image

Here is the error message from Output > Python:

LSP Notebooks experiment is disabled -- not in treatment group

python -c "import sys;print(sys.executable)" python -c "import sys;print(sys.executable)" Python interpreter path: /usr/local/bin/python python -c "import sys;print(sys.executable)" Starting Pylance language server. python -c "import sys;print(sys.executable)" python -c "import sys;print(sys.executable)" python -c "import sys;print(sys.executable)" python -c "import sys;print(sys.executable)" python ./.vscode-server/extensions/ms-python.python-2022.10.1/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir . -s --cache-clear workflow cwd: . [ERROR 2022-6-26 13:1:2.338]: Error discovering pytest tests: [n [Error]: Traceback (most recent call last): File "/home/cdsw/.vscode-server/extensions/ms-python.python-2022.10.1/pythonFiles/testing_tools/run_adapter.py", line 17, in from testing_tools.adapter.main import parse_args, main File "/home/cdsw/.vscode-server/extensions/ms-python.python-2022.10.1/pythonFiles/testing_tools/adapter/main.py", line 9, in from . import pytest, report File "/home/cdsw/.vscode-server/extensions/ms-python.python-2022.10.1/pythonFiles/testing_tools/adapter/pytest/init.py", line 7, in from ._discovery import discover File "/home/cdsw/.vscode-server/extensions/ms-python.python-2022.10.1/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 8, in import pytest ImportError: No module named pytest

at ChildProcess. (/home/cdsw/.vscode-server/extensions/ms-python.python-2022.10.1/out/client/extension.js:2:232783) at Object.onceWrapper (node:events:510:26) at ChildProcess.emit (node:events:390:28) at maybeClose (node:internal/child_process:1064:16) at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)]

python -c "import sys;print(sys.executable)"

Steps to reproduce:

  1. Click the Testing button in the side bar

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 3.6.13
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Global
  • 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)

XXX

User Settings


languageServer: "Pylance"

linting
• flake8Args: "<placeholder>"

sortImports
• args: "<placeholder>"

formatting
• provider: "black"

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

Extension version: 2022.10.1 VS Code version: Code 1.69.2 (3b889b090b5ad5793f524b5d1d39fda662b96a2a, 2022-07-18T16:12:52.460Z) OS version: Windows_NT x64 10.0.19042 Restricted Mode: No Remote OS version: Linux x64 3.10.0-1160.59.1.el7.x86_64

System Info
Item Value
CPUs 11th Gen Intel® Core™ i5-1145G7 @ 2.60GHz (8 x 1498)
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
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) undefined
Memory (System) 15.73GB (5.70GB free)
Process Argv –crash-reporter-id bbd9672c-80fc-4ddb-9d19-83961752b2ab
Screen Reader no
VM 0%
Item Value
Remote SSH: deo
OS Linux x64 3.10.0-1160.59.1.el7.x86_64
CPUs Intel® Xeon® CPU E5-2697A v4 @ 2.60GHz (64 x 2597)
Memory (System) 251.62GB (160.16GB free)
VM 0%
A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vswsl492:30256859
vslsvsres303:30308271
pythonvspyl392:30443607
vserr242:30382549
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscorecescf:30445987
pythondataviewer:30285071
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
cmake_vspar411cf:30525689
vsaa593cf:30376535
vsc1dst:30438360
pythonvs932:30410667
wslgetstarted:30449410
vscscmwlcmt:30465135
cppdebug:30492333
pylanb8912cf:30529770
vsclangdc:30486549
c4g48928:30534093

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (4 by maintainers)

Most upvoted comments

Fix should be out in the pre-release version of the extension in a few minutes, use the following to try it out, make sure to run Python: Clear workspace interpreter setting command to clear any workspace configs, and the double-check the list to see which one we recommend:

image

@franva Thanks for the info, I have ensured interpreters with issues appear towards the end of the list, so they’re not autoselected. And we select the first non-conda global interpreters, if no interpreters exist in the workspace.