Received JSON data in run script
Running pytest with args: ['-p', 'vscode_pytest', '--rootdir=h:\\python\\django-vscode-pytest', 'h:\\python\\django-vscode-pytest\\test_Foo.py::test_pass']
============================= test session starts =============================
platform win32 -- Python 3.11.7, pytest-8.3.2, pluggy-1.5.0
rootdir: h:\python\django-vscode-pytest
configfile: pyproject.toml
plugins: django-4.9.0, xdist-3.6.1
created: 4/4 workers
4 workers [1 item]
s [100%]Error attempting to connect to extension named pipe \\.\pipe\python-test-results-475b03408672b927dda0-sock[vscode-pytest]: [Errno 2] No such file or directory: '\\\\.\\pipe\\python-test-results-475b03408672b927dda0-sock'
If you are on a Windows machine, this error may be occurring if any of your tests clear environment variables as they are required to communicate with the extension. Please reference https://docs.pytest.org/en/stable/how-to/monkeypatch.html#monkeypatching-environment-variablesfor the correct way to clear environment variables during testing.
Traceback (most recent call last):
File "c:\Users\Piotr\.vscode\extensions\ms-python.python-2024.12.2-win32-x64\python_files\vscode_pytest\__init__.py", line 857, in send_post_request
__writer.connect()
File "c:\Users\Piotr\.vscode\extensions\ms-python.python-2024.12.2-win32-x64\python_files\testing_tools\socket_manager.py", line 24, in connect
self._writer = open(self.name, "w", encoding="utf-8") # noqa: SIM115, PTH123
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '\\\\.\\pipe\\python-test-results-475b03408672b927dda0-sock'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "c:\Users\Piotr\.vscode\extensions\ms-python.python-2024.12.2-win32-x64\python_files\vscode_pytest\run_pytest_script.py", line 73, in <module>
pytest.main(arg_array)
File "h:\python\django-vscode-pytest\.venv\Lib\site-packages\_pytest\config\__init__.py", line 175, in main
ret: ExitCode | int = config.hook.pytest_cmdline_main(config=config)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "h:\python\django-vscode-pytest\.venv\Lib\site-packages\pluggy\_hooks.py", line 513, in __call__
return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "h:\python\django-vscode-pytest\.venv\Lib\site-packages\pluggy\_manager.py", line 120, in _hookexec
return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "h:\python\django-vscode-pytest\.venv\Lib\site-packages\pluggy\_callers.py", line 139, in _multicall
raise exception.with_traceback(exception.__traceback__)
File "h:\python\django-vscode-pytest\.venv\Lib\site-packages\pluggy\_callers.py", line 103, in _multicall
res = hook_impl.function(*args)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "h:\python\django-vscode-pytest\.venv\Lib\site-packages\_pytest\main.py", line 330, in pytest_cmdline_main
return wrap_session(config, _main)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "h:\python\django-vscode-pytest\.venv\Lib\site-packages\_pytest\main.py", line 318, in wrap_session
config.hook.pytest_sessionfinish(
File "h:\python\django-vscode-pytest\.venv\Lib\site-packages\pluggy\_hooks.py", line 513, in __call__
return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "h:\python\django-vscode-pytest\.venv\Lib\site-packages\pluggy\_manager.py", line 120, in _hookexec
return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "h:\python\django-vscode-pytest\.venv\Lib\site-packages\pluggy\_callers.py", line 139, in _multicall
raise exception.with_traceback(exception.__traceback__)
File "h:\python\django-vscode-pytest\.venv\Lib\site-packages\pluggy\_callers.py", line 122, in _multicall
teardown.throw(exception) # type: ignore[union-attr]
^^^^^^^^^^^^^^^^^^^^^^^^^
File "h:\python\django-vscode-pytest\.venv\Lib\site-packages\_pytest\logging.py", line 870, in pytest_sessionfinish
return (yield)
^^^^^
File "h:\python\django-vscode-pytest\.venv\Lib\site-packages\pluggy\_callers.py", line 122, in _multicall
teardown.throw(exception) # type: ignore[union-attr]
^^^^^^^^^^^^^^^^^^^^^^^^^
File "h:\python\django-vscode-pytest\.venv\Lib\site-packages\_pytest\terminal.py", line 893, in pytest_sessionfinish
result = yield
^^^^^
File "h:\python\django-vscode-pytest\.venv\Lib\site-packages\pluggy\_callers.py", line 122, in _multicall
teardown.throw(exception) # type: ignore[union-attr]
^^^^^^^^^^^^^^^^^^^^^^^^^
File "h:\python\django-vscode-pytest\.venv\Lib\site-packages\_pytest\warnings.py", line 141, in pytest_sessionfinish
return (yield)
^^^^^
File "h:\python\django-vscode-pytest\.venv\Lib\site-packages\pluggy\_callers.py", line 103, in _multicall
res = hook_impl.function(*args)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\Piotr\.vscode\extensions\ms-python.python-2024.12.2-win32-x64\python_files\vscode_pytest\__init__.py", line 425, in pytest_sessionfinish
send_post_request(payload)
File "c:\Users\Piotr\.vscode\extensions\ms-python.python-2024.12.2-win32-x64\python_files\vscode_pytest\__init__.py", line 868, in send_post_request
raise VSCodePytestError(error_msg) from error
vscode_pytest.VSCodePytestError: Error attempting to connect to extension named pipe \\.\pipe\python-test-results-475b03408672b927dda0-sock[vscode-pytest]: [Errno 2] No such file or directory: '\\\\.\\pipe\\python-test-results-475b03408672b927dda0-sock'
Finished running tests!
Type: Bug
Behaviour
I have the following setup:
pyproject.toml:
test_Foo.py:
I have also enabled the
pythonTestAdapterexperiment.When I run this test (using the Testing panel), I get the result:
The test is skipped (that is expected, I removed Django to create minimal example, and
pytest-djangoskips tests that require Django).Next, I add the
-n 4option topytest:Now, when I run the test exactly as before, the test fails unexpetedly with error
vscode_pytest.VSCodePytestError: Error attempting to connect to extension named pipe.Steps to reproduce:
As above.
Diagnostic data
Output for
Pythonin theOutputpanel (View→Output, change the drop-down the upper-right of theOutputpanel toPython)Extension version: 2024.12.2
VS Code version: Code 1.92.2 (fee1edb8d6d72a0ddff41e5f71a671c23ed924b9, 2024-08-14T17:29:30.058Z)
OS version: Windows_NT x64 10.0.22631
Modes:
python.languageServersetting: DefaultUser Settings
Installed Extensions