Skip to content

Test discovery with pytest fails, because pytest is run in the base conda env #24122

Closed

Description

Type: Bug

Behaviour

Test discovery with pytest fails.

From looking at the output, it seems that pytest is run in my base conda environment, not in the environment for this particular project. My base conda environment has an old, no longer supported Python version and no pytest installed; however, a recent version of python and pytest are installed in the environment that I use for this project and that I want to run the tests in.

I verified that "Python: Select Interpreter ..." is set to the correct environment and this is confirmed by the little icon on the status bar at the bottom right that displays "Python 3.11.7 ('sherpaciao')", where "sherpaciao" is a conda env with pytest. Running pytest in the terminal in that conda env works as extected.

Note that the condo env in the Python output (see full output below) is set to "CONDA_PREFIX":"/Users/guenther/mambaforge","CONDA_PROMPT_MODIFIER":"(base) while the warning a few lines down from that addresses the correct conda env: [warning] could not find a pixi interpreter for the interpreter at /Users/guenther/mambaforge/envs/sherpaciao/bin/python.

Steps to reproduce:

I hope that this can be debugged from the console/setting output since it's probably related to some setting that is wrong; I suspect that it's not easy to reproduce.

Diagnostic data

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

2024-09-17 11:53:33.212 [info] Discover tests for workspace name: sherpa - uri: /Users/guenther/code/sherpa
2024-09-17 11:53:33.212 [info] Running discovery for pytest using the new test adapter.
2024-09-17 11:53:33.213 [info] All environment variables set for pytest discovery: {"ADS_API_TOKEN":"WPnK3GVwUCbcUvZzM2JcvKAkngy9lg2DPNS8Ss3A","COMMAND_MODE":"unix2003","CONDA_DEFAULT_ENV":"base","CONDA_EXE":"/Users/guenther/mambaforge/bin/conda","CONDA_PREFIX":"/Users/guenther/mambaforge","CONDA_PROMPT_MODIFIER":"(base) ","CONDA_PYTHON_EXE":"/Users/guenther/mambaforge/bin/python","CONDA_SHLVL":"1","DISPLAY":"/private/tmp/com.apple.launchd.T5UouRP3vi/org.xquartz:0","HOME":"/Users/guenther","LOGNAME":"guenther","MallocNanoZone":"0","OLDPWD":"/","ORIGINAL_XDG_CURRENT_DESKTOP":"undefined","PS1":"(base) %m %~> ","PWD":"/","SHELL":"/bin/zsh","SHLVL":"0","SSH_AUTH_SOCK":"/private/tmp/com.apple.launchd.9lE2FhSB4I/Listeners","TMPDIR":"/var/folders/r7/f0qh27rn207bwwvt3s7v5gh40000gn/T/","USER":"guenther","VSCODE_AMD_ENTRYPOINT":"vs/workbench/api/node/extensionHostProcess","VSCODE_CODE_CACHE_PATH":"/Users/guenther/Library/Application Support/Code/CachedData/38c31bc77e0dd6ae88a4e9cc93428cc27a56ba40","VSCODE_CRASH_REPORTER_PROCESS_TYPE":"extensionHost","VSCODE_CWD":"/","VSCODE_HANDLES_UNCAUGHT_ERRORS":"true","VSCODE_IPC_HOOK":"/Users/guenther/Library/Application Support/Code/1.93-main.sock","VSCODE_NLS_CONFIG":"{\"userLocale\":\"en-us\",\"osLocale\":\"en-us\",\"resolvedLanguage\":\"en\",\"defaultMessagesFile\":\"/Applications/Visual Studio Code.app/Contents/Resources/app/out/nls.messages.json\",\"locale\":\"en-us\",\"availableLanguages\":{}}","VSCODE_PID":"83602","XPC_FLAGS":"0x0","XPC_SERVICE_NAME":"application.com.microsoft.VSCode.82204521.82204529","XUVTOP":"/Users/guenther/data/CHIANTI","_":"/Applications/Visual Studio Code.app/Contents/MacOS/Electron","__CFBundleIdentifier":"com.microsoft.VSCode","__CF_USER_TEXT_ENCODING":"0x1F5:0x0:0x0","ELECTRON_RUN_AS_NODE":"1","VSCODE_L10N_BUNDLE_LOCATION":"","PATH":"/Users/guenther/mambaforge/bin:/Users/guenther/mambaforge/condabin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/opt/X11/bin:/Library/Apple/usr/bin:/Library/TeX/texbin","PYTHONPATH":"/Users/guenther/.vscode/extensions/ms-python.python-2024.14.1-darwin-arm64/python_files","TEST_RUN_PIPE":"/var/folders/r7/f0qh27rn207bwwvt3s7v5gh40000gn/T/python-test-discovery-331c548a6db514ee3062.sock"}
2024-09-17 11:53:33.214 [warning] could not find a pixi interpreter for the interpreter at /Users/guenther/mambaforge/envs/sherpaciao/bin/python
2024-09-17 11:53:33.216 [info] > python -m pytest -p vscode_pytest --collect-only
2024-09-17 11:53:33.216 [info] cwd: .
2024-09-17 11:53:33.272 [error] /Users/guenther/mambaforge/bin/python: No module named pytest

2024-09-17 11:53:33.275 [error] Subprocess exited unsuccessfully with exit code 1 and signal null on workspace /Users/guenther/code/sherpa.
2024-09-17 11:53:33.275 [error] Subprocess exited unsuccessfully with exit code 1 and signal null on workspace /Users/guenther/code/sherpa. Creating and sending error discovery payload
2024-09-17 11:53:33.275 [error] pytest test discovery error for workspace:  /Users/guenther/code/sherpa 
  
 The python test process was terminated before it could exit on its own, the process errored with: Code: 1, Signal: null for workspace /Users/guenther/code/sherpa
2024-09-17 12:07:41.517 [info] Native locator: Refresh started
2024-09-17 12:07:41.559 [info] Conda environment manager found at: /Users/guenther/mambaforge/bin/conda
2024-09-17 12:07:41.739 [info] Native locator: Refresh finished in 199 ms

Extension version: 2024.14.1
VS Code version: Code 1.93.1 (Universal) (38c31bc77e0dd6ae88a4e9cc93428cc27a56ba40, 2024-09-11T17:20:05.685Z)
OS version: Darwin arm64 23.6.0
Modes:

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


languageServer: "Pylance"

testing
• pytestEnabled: true

Installed Extensions
Extension Name Extension Id Version
Code Spell Checker streetsidesoftware.code-spell-checker 3.0.1
GitHub Actions github.vscode-github-actions 0.26.5
GitHub Copilot GitHub.copilot 1.229.0
GitHub Copilot Chat GitHub.copilot-chat 0.20.1
GitHub Pull Requests GitHub.vscode-pull-request-github 0.96.0
GitLens — Git supercharged eamodio.gitlens 15.5.1
JavaScript Debugger ms-vscode.js-debug 1.93.0
JavaScript Debugger Companion Extension ms-vscode.js-debug-companion 1.1.3
Jupyter ms-toolsai.jupyter 2024.8.1
Jupyter Cell Tags ms-toolsai.vscode-jupyter-cell-tags 0.1.9
Jupyter Keymap ms-toolsai.jupyter-keymap 1.1.2
Jupyter Notebook Renderers ms-toolsai.jupyter-renderers 1.0.19
LaTeX Workshop James-Yu.latex-workshop 10.3.2
Live Server ritwickdey.LiveServer 5.7.9
LTeX – LanguageTool grammar/spell checking valentjn.vscode-ltex 13.1.0
Makefile Tools ms-vscode.makefile-tools 0.11.13
Pylance ms-python.vscode-pylance 2024.9.1
Python ms-python.python 2024.14.1
Python Debugger ms-python.debugpy 2024.10.0
Table Visualizer for JavaScript Profiles ms-vscode.vscode-js-profile-table 1.0.9
Trailing Whitespace jkiviluoto.tws 1.0.1
System Info
Item Value
CPUs Apple M1 (8 x 2400)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
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_graphite: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) 4, 3, 3
Memory (System) 16.00GB (0.09GB free)
Process Argv --crash-reporter-id e2a97932-7d55-44e5-bb05-555f7819c1cd
Screen Reader no
VM 0%
A/B Experiments
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805cf:30301675
binariesv615:30325510
vsaa593:30376534
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyone:30548225
962ge761:30959799
pythongtdpath:30769146
welcomedialogc:30910334
pythonnoceb:30805159
asynctok:30898717
pythonmypyd1:30879173
h48ei257:31000450
pythontbext0:30879054
accentitlementsc:30995553
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
dsvsc021:30996838
bdiig495:31013172
a69g1124:31058053
dvdeprecation:31068756
dwnewjupytercf:31046870
newcmakeconfigv2:31071590
impr_priority:31102340
nativerepl1:31139838
refactort:31108082
pythonrstrctxt:31112756
flightc:31134773
wkspc-onlycs-t:31132770
nativeloc1:31134641
wkspc-ranged-c:31125598
cf971741:31134768
pme_test_t:31118333
defaultse:31133495
ei213698:31121563
iacca1:31138162

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Labels

area-testingbugIssue identified by VS Code Team member as probable buginfo-neededIssue requires more information from postertriage-neededNeeds assignment to the proper sub-team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions