Type: Bug
Behaviour
Even if I installed pytest in the venv and selected the interpretor, it still use the pytest of my system while testing. I had to modify python.testing.pytestPath to ${workspaceFolder}/.venv/bin/pytest to get it worked.
There is no error performing my tests in the terminal within the venv activated
Steps to reproduce:
- create a project and an virtual env without pip
- install pytest in the virtual env
- install the project as editable mode with
pip install -e
- add a test file which contains import of the project
from myproject import foo
- run test in the sidebar
Diagnostic data
python test log panel
=============================
platform linux -- Python 3.12.3, pytest-8.1.2, pluggy-1.4.0
rootdir: /mnt/lib/develop/sources/python/cphub
configfile: pyproject.toml
plugins: typeguard-4.2.1, anyio-4.3.0, mock-3.14.0
collected 0 items / 1 error
==================================== ERRORS ====================================
___________________ ERROR collecting tests/test_pastebin.py ____________________
ImportError while importing test module '/mnt/lib/develop/sources/python/cphub/tests/test_pastebin.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib/python3.12/importlib/__init__.py:90: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
tests/test_pastebin.py:4: in <module>
from cphub.pastebin import PasteBin
E ModuleNotFoundError: No module named 'cphub'
-------------- generated xml file: /tmp/tmp-88939gx50f6ouwSFD.xml --------------
=========================== short test summary info ============================
ERROR tests/test_pastebin.py
=============================== 1 error in 0.03s ===============================
ERROR: found no collectors for /mnt/lib/develop/sources/python/cphub/tests/test_pastebin.py::test_singleton_instance
Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)
2024-05-10 17:59:35.532 [info] > ~/.local/bin/pytest --rootdir . --override-ini junit_family=xunit1 --junit-xml=/tmp/tmp-88939gx50f6ouwSFD.xml ./tests/test_pastebin.py::test_singleton_instance
2024-05-10 17:59:35.533 [info] cwd: .
Extension version: 2024.7.11301009
VS Code version: Code - Insiders 1.90.0-insider (ccba2fc, 2024-05-06T08:06:22.239Z)
OS version: Linux x64 6.8.9-zen1-1-zen
Modes:
- Python version (& distribution if applicable, e.g. Anaconda): 3.10.14
- Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Venv
- Value of the
python.languageServer setting: Pylance
User Settings
venvPath: "<placeholder>"
venvFolders: "${workspaceFolder}/.venv"
languageServer: "Pylance"
testing
• cwd: "${workspaceFolder}"
• pytestArgs: "${workspaceFolder}/tests"
• pytestEnabled: true
• pytestPath: "<placeholder>"
Installed Extensions
| Extension Name |
Extension Id |
Version |
| Auto Close Tag |
formulahendry.auto-close-tag |
0.5.15 |
| Auto Rename Tag |
formulahendry.auto-rename-tag |
0.1.10 |
| Even Better TOML |
tamasfe.even-better-toml |
0.19.2 |
| gitignore |
codezombiech.gitignore |
0.9.0 |
| Indenticator |
SirTori.indenticator |
0.7.0 |
| IntelliCode |
VisualStudioExptTeam.vscodeintellicode |
1.3.1 |
| IntelliCode API Usage Examples |
VisualStudioExptTeam.intellicode-api-usage-examples |
0.2.8 |
| json |
ZainChen.json |
2.0.2 |
| Live Server |
ritwickdey.LiveServer |
5.7.9 |
| Markdown All in One |
yzhang.markdown-all-in-one |
3.6.2 |
| Path Intellisense |
christian-kohler.path-intellisense |
2.8.5 |
| Prettify JSON |
mohsen1.prettify-json |
0.0.3 |
| Project Manager |
alefragnani.project-manager |
12.8.0 |
| Pylance |
ms-python.vscode-pylance |
2024.5.1 |
| Python |
ms-python.python |
2024.7.11301009 |
| Python Debugger |
ms-python.debugpy |
2024.6.0 |
| Python Extension Pack |
donjayamanne.python-extension-pack |
1.7.0 |
| Python Indent |
KevinRose.vsc-python-indent |
1.18.0 |
| Python Test Explorer for Visual Studio Code |
littlefoxteam.vscode-python-test-adapter |
0.8.2 |
| Python Type Hint |
njqdev.vscode-python-typehint |
1.5.1 |
| Remote - SSH |
ms-vscode-remote.remote-ssh |
0.112.2024050815 |
| Remote - SSH: Editing Configuration Files |
ms-vscode-remote.remote-ssh-edit |
0.86.0 |
| Remote Explorer |
ms-vscode.remote-explorer |
0.5.2024031109 |
| Remote Repositories |
ms-vscode.remote-repositories |
0.41.2024022202 |
| Ruff |
charliermarsh.ruff |
2024.20.0 |
| Table Visualizer for JavaScript Profiles |
ms-vscode.vscode-js-profile-table |
1.0.9 |
| Tabnine AI |
TabNine.tabnine-vscode |
3.98.0 |
| Test Adapter Converter |
ms-vscode.test-adapter-converter |
0.1.9 |
| Test Explorer UI |
hbenl.vscode-test-explorer |
2.21.1 |
| Todo Tree |
Gruntfuggly.todo-tree |
0.0.226 |
| Tokyo Night |
enkia.tokyo-night |
1.0.6 |
| Wal Theme |
dlasagno.wal-theme |
1.2.0 |
| YAML |
redhat.vscode-yaml |
1.14.0 |
System Info
| Item |
Value |
| CPUs |
AMD Ryzen 5 3600 6-Core Processor (12 x 4016) |
| 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_graphite: disabled_off video_decode: enabled video_encode: disabled_software vulkan: disabled_off webgl: enabled webgl2: enabled webgpu: disabled_off |
| Load (avg) |
1, 1, 1 |
| Memory (System) |
15.51GB (8.74GB free) |
| Process Argv |
--unity-launch --enable-features=UseOzonePlatform --ozone-platform=wayland --password-store=gnome --enable-wayland-ime |
| Screen Reader |
no |
| VM |
0% |
| DESKTOP_SESSION |
plasma |
| XDG_CURRENT_DESKTOP |
KDE |
| XDG_SESSION_DESKTOP |
plasma |
| XDG_SESSION_TYPE |
wayland |
Type: Bug
Behaviour
Even if I installed pytest in the venv and selected the interpretor, it still use the pytest of my system while testing. I had to modify
python.testing.pytestPathto${workspaceFolder}/.venv/bin/pytestto get it worked.There is no error performing my tests in the terminal within the venv activated
Steps to reproduce:
pip install -efrom myproject import fooDiagnostic data
python test log panel
Output for
Pythonin theOutputpanel (View→Output, change the drop-down the upper-right of theOutputpanel toPython)Extension version: 2024.7.11301009
VS Code version: Code - Insiders 1.90.0-insider (ccba2fc, 2024-05-06T08:06:22.239Z)
OS version: Linux x64 6.8.9-zen1-1-zen
Modes:
python.languageServersetting: PylanceUser Settings
Installed Extensions
System Info
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_graphite: disabled_off
video_decode: enabled
video_encode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off