You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I set up a small python project (using pdm & pytest). I can run all the unit tests from within vscode using the TESTING tab. However when I try to debug a test, I will get the following error message on the TEST_RESULTS tab:
Error while running tests: test_conan_info_version_foo
TypeError: Cannot read properties of null (reading 'testsuites')
Error while running tests:
TypeError: Cannot read properties of null (reading 'testsuites')
I am using Debian Bookworm in WSL and running VSCode on Win11.
Steps to reproduce:
Create new folder foo in your home directory in WSL (I tried using Debian Bookworm)
cd foo
run pdm init
run pdm add pytest
Create new file tests/foo_test.py. Content:
deftest_foo():
assertFalse
Enable the vscode testing, choose: pytest, choost tests folder as test folder
Run the test once. It should fail with assert False.
Set a breakpoint in line 2 of foo_test.py
Right-click on the red cross in line 1 of foo_test.py and choose Debug Test
The error will occur as described.
Diagnostic data
Debug console shows:
Traceback (most recent call last):
File "/usr/lib/python3.11/runpy.py", line 198, in _run_module_as_main
return _run_code(code, main_globals, None,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/runpy.py", line 88, in _run_code
exec(code, run_globals)
File "/home/schwaerz/.vscode-server/extensions/ms-python.debugpy-2024.6.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/__main__.py", line 39, in <module>
cli.main()
File "/home/schwaerz/.vscode-server/extensions/ms-python.debugpy-2024.6.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 430, in main
run()
File "/home/schwaerz/.vscode-server/extensions/ms-python.debugpy-2024.6.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 284, in run_file
runpy.run_path(target, run_name="__main__")
File "/home/schwaerz/.vscode-server/extensions/ms-python.debugpy-2024.6.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 321, in run_path
return _run_module_code(code, init_globals, run_name,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/schwaerz/.vscode-server/extensions/ms-python.debugpy-2024.6.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 135, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/home/schwaerz/.vscode-server/extensions/ms-python.debugpy-2024.6.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 124, in _run_code
exec(code, run_globals)
File "/home/schwaerz/.vscode-server/extensions/ms-python.python-2024.10.0-linux-x64/python_files/testlauncher.py", line 44, in <module>
run(cwd, testRunner, args)
File "/home/schwaerz/.vscode-server/extensions/ms-python.python-2024.10.0-linux-x64/python_files/testlauncher.py", line 36, in run
pytest.main(args)
File "/home/schwaerz/repositories/foo/.venv/lib/python3.11/site-packages/_pytest/config/__init__.py", line 159, in main
config = _prepareconfig(args, plugins)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/schwaerz/repositories/foo/.venv/lib/python3.11/site-packages/_pytest/config/__init__.py", line 346, in _prepareconfig
config = pluginmanager.hook.pytest_cmdline_parse(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/schwaerz/repositories/foo/.venv/lib/python3.11/site-packages/pluggy/_hooks.py", line 513, in __call__
return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/schwaerz/repositories/foo/.venv/lib/python3.11/site-packages/pluggy/_manager.py", line 120, in _hookexec
return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/schwaerz/repositories/foo/.venv/lib/python3.11/site-packages/pluggy/_callers.py", line 139, in _multicall
raise exception.with_traceback(exception.__traceback__)
File "/home/schwaerz/repositories/foo/.venv/lib/python3.11/site-packages/pluggy/_callers.py", line 122, in _multicall
teardown.throw(exception) # type: ignore[union-attr]
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/schwaerz/repositories/foo/.venv/lib/python3.11/site-packages/_pytest/helpconfig.py", line 106, in pytest_cmdline_parse
config = yield
^^^^^
File "/home/schwaerz/repositories/foo/.venv/lib/python3.11/site-packages/pluggy/_callers.py", line 103, in _multicall
res = hook_impl.function(*args)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/schwaerz/repositories/foo/.venv/lib/python3.11/site-packages/_pytest/config/__init__.py", line 1152, in pytest_cmdline_parse
self.parse(args)
File "/home/schwaerz/repositories/foo/.venv/lib/python3.11/site-packages/_pytest/config/__init__.py", line 1501, in parse
self._preparse(args, addopts=addopts)
File "/home/schwaerz/repositories/foo/.venv/lib/python3.11/site-packages/_pytest/config/__init__.py", line 1373, in _preparse
self._initini(args)
File "/home/schwaerz/repositories/foo/.venv/lib/python3.11/site-packages/_pytest/config/__init__.py", line 1247, in _initini
rootpath, inipath, inicfg = determine_setup(
^^^^^^^^^^^^^^^^
File "/home/schwaerz/repositories/foo/.venv/lib/python3.11/site-packages/_pytest/config/findpaths.py", line 201, in determine_setup
rootdir, inipath, inicfg = locate_config(invocation_dir, [ancestor])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/schwaerz/repositories/foo/.venv/lib/python3.11/site-packages/_pytest/config/findpaths.py", line 113, in locate_config
ini_config = load_config_dict_from_file(p)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/schwaerz/repositories/foo/.venv/lib/python3.11/site-packages/_pytest/config/findpaths.py", line 69, in load_config_dict_from_file
toml_text = filepath.read_text(encoding="utf-8")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/pathlib.py", line 1058, in read_text
encoding = io.text_encoding(encoding)
^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/io.py", line 73, in __getattr__
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
AttributeError: module 'io' has no attribute 'text_encoding'
Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)
2024-07-09 18:53:38.186 [info] Environments refresh finished (event): 3632 milliseconds
2024-07-09 18:53:38.186 [info] Environments refresh finished (event): 2425 milliseconds
2024-07-09 18:53:38.188 [info] Environment refresh took 3635 milliseconds
2024-07-09 18:53:38.189 [info] Environment refresh took 2428 milliseconds
2024-07-09 18:53:38.191 [info] > pyenv which python
2024-07-09 18:53:38.191 [info] cwd: .
2024-07-09 18:53:38.346 [warning] could not find a pixi interpreter for the interpreter at /home/schwaerz/repositories/foo/.venv/bin/python
2024-07-09 18:53:38.350 [info] Python interpreter path: ./.venv/bin/python
2024-07-09 18:53:39.781 [info] Starting Pylance language server.
2024-07-09 18:54:36.084 [info] Discover tests for workspace name: foo - uri: /home/schwaerz/repositories/foo/tests/test.py
2024-07-09 18:54:39.281 [info] Discover tests for workspace name: foo - uri: /home/schwaerz/repositories/foo/tests/test.py
2024-07-09 18:54:42.606 [info] Discover tests for workspace name: foo - uri: /home/schwaerz/repositories/foo
2024-07-09 18:54:46.258 [warning] could not find a pixi interpreter for the interpreter at /home/schwaerz/repositories/foo/.venv/bin/python
2024-07-09 18:54:46.365 [info] Send text to terminal: source /home/schwaerz/repositories/foo/.venv/bin/activate
2024-07-09 18:54:50.228 [info] Discover tests for workspace name: foo - uri: /home/schwaerz/repositories/foo
2024-07-09 18:54:54.120 [warning] could not find a pixi interpreter for the interpreter at /home/schwaerz/repositories/foo/.venv/bin/python
2024-07-09 18:54:54.131 [info] > . ./.venv/bin/activate && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python ~/.vscode-server/extensions/ms-python.python-2024.10.0-linux-x64/python_files/printEnvVariables.py
2024-07-09 18:54:54.131 [info] shell: bash
2024-07-09 18:54:54.166 [warning] could not find a pixi interpreter for the interpreter at /home/schwaerz/repositories/foo/.venv/bin/python
2024-07-09 18:54:54.170 [info] > ./.venv/bin/python -c "import pytest"
2024-07-09 18:54:54.977 [info] Discover tests for workspace name: foo - uri: /home/schwaerz/repositories/foo/.vscode/settings.json
2024-07-09 18:54:55.354 [info] Discover tests for workspace name: foo - uri: /home/schwaerz/repositories/foo/.vscode/settings.json
2024-07-09 18:54:55.699 [info] Discover tests for workspace name: foo - uri: /home/schwaerz/repositories/foo/.vscode/settings.json
2024-07-09 18:54:55.700 [warning] could not find a pixi interpreter for the interpreter at /home/schwaerz/repositories/foo/.venv/bin/python
2024-07-09 18:54:55.712 [info] > . ./.venv/bin/activate && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python ~/.vscode-server/extensions/ms-python.python-2024.10.0-linux-x64/python_files/printEnvVariables.py
2024-07-09 18:54:55.712 [info] shell: bash
2024-07-09 18:54:55.746 [warning] could not find a pixi interpreter for the interpreter at /home/schwaerz/repositories/foo/.venv/bin/python
2024-07-09 18:54:55.750 [info] > ./.venv/bin/python ~/.vscode-server/extensions/ms-python.python-2024.10.0-linux-x64/python_files/testing_tools/run_adapter.py discover pytest -- --rootdir . -s --cache-clear tests
2024-07-09 18:54:55.751 [info] cwd: .
2024-07-09 18:54:56.232 [info] Discover tests for workspace name: foo - uri: /home/schwaerz/repositories/foo
2024-07-09 18:54:56.232 [warning] could not find a pixi interpreter for the interpreter at /home/schwaerz/repositories/foo/.venv/bin/python
2024-07-09 18:54:56.235 [info] > ./.venv/bin/python ~/.vscode-server/extensions/ms-python.python-2024.10.0-linux-x64/python_files/testing_tools/run_adapter.py discover pytest -- --rootdir . -s --cache-clear tests
2024-07-09 18:54:56.235 [info] cwd: .
2024-07-09 18:55:01.789 [info] Discover tests for workspace name: foo - uri: /home/schwaerz/repositories/foo
2024-07-09 18:55:01.790 [warning] could not find a pixi interpreter for the interpreter at /home/schwaerz/repositories/foo/.venv/bin/python
2024-07-09 18:55:01.793 [info] > ./.venv/bin/python ~/.vscode-server/extensions/ms-python.python-2024.10.0-linux-x64/python_files/testing_tools/run_adapter.py discover pytest -- --rootdir . -s --cache-clear tests
2024-07-09 18:55:01.793 [info] cwd: .
2024-07-09 18:55:05.149 [warning] could not find a pixi interpreter for the interpreter at /home/schwaerz/repositories/foo/.venv/bin/python
2024-07-09 18:55:05.152 [info] > ./.venv/bin/python -c "import pytest"
2024-07-09 18:55:21.248 [info] Discover tests for workspace name: foo - uri: /home/schwaerz/repositories/foo
2024-07-09 18:55:21.248 [warning] could not find a pixi interpreter for the interpreter at /home/schwaerz/repositories/foo/.venv/bin/python
2024-07-09 18:55:21.252 [info] > ./.venv/bin/python ~/.vscode-server/extensions/ms-python.python-2024.10.0-linux-x64/python_files/testing_tools/run_adapter.py discover pytest -- --rootdir . -s --cache-clear tests
2024-07-09 18:55:21.252 [info] cwd: .
2024-07-09 18:56:49.174 [warning] could not find a pixi interpreter for the interpreter at /home/schwaerz/repositories/foo/.venv/bin/python
2024-07-09 18:56:49.178 [info] > ./.venv/bin/python -m pytest --rootdir . --override-ini junit_family=xunit1 --junit-xml=/tmp/tmp-16777oWev4uGdPPR5.xml ./tests/foo_test.py::test_foo
2024-07-09 18:56:49.178 [info] cwd: .
2024-07-09 18:58:40.056 [info] Using launch configuration in workspace folder.
2024-07-09 18:58:40.247 [info] CreateEnv Trigger - Skipping for /home/schwaerz/repositories/foo
Extension version: 2024.10.0
VS Code version: Code 1.91.0 (ea1445cc7016315d0f5728f8e8b12a45dc0a7286, 2024-07-01T18:52:22.949Z)
OS version: Windows_NT x64 10.0.22631
Modes:
Remote OS version: Linux x64 5.15.123.1-microsoft-standard-WSL2
Python version (& distribution if applicable, e.g. Anaconda): 3.11.2
Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Venv
Value of the python.languageServer setting: Pylance
Hi! It looks like you are using the python extension without the testing rewrite which should fix your issue. Please opt in and give it another try. You can opt in by adding the following to your user settings: "python.experiments.optInto": ["pythonTestAdapter"],
Type: Bug
Behaviour
I set up a small python project (using pdm & pytest). I can run all the unit tests from within vscode using the TESTING tab. However when I try to debug a test, I will get the following error message on the TEST_RESULTS tab:
I am using Debian Bookworm in WSL and running VSCode on Win11.
Steps to reproduce:
foo
in your home directory in WSL (I tried using Debian Bookworm)cd foo
pdm init
pdm add pytest
tests/foo_test.py
. Content:tests
folder as test folderassert False
.foo_test.py
foo_test.py
and chooseDebug Test
The error will occur as described.
Diagnostic data
Debug console shows:
Output for
Python
in theOutput
panel (View
→Output
, change the drop-down the upper-right of theOutput
panel toPython
)Extension version: 2024.10.0
VS Code version: Code 1.91.0 (ea1445cc7016315d0f5728f8e8b12a45dc0a7286, 2024-07-01T18:52:22.949Z)
OS version: Windows_NT x64 10.0.22631
Modes:
Remote OS version: Linux x64 5.15.123.1-microsoft-standard-WSL2
python.languageServer
setting: PylanceUser Settings
Installed Extensions
System Info
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
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
The text was updated successfully, but these errors were encountered: