vscode-python: Unable to run tests with `pythonTestAdapter` enabled
Type: Bug
Behaviour
Expected vs. Actual
Tests are currently not running for me using the python testing plugin as previous. When I run a test by clicking the GUI arrow in the test pane, the test hangs indefinitely. In the Python Test Log, I get the following error:
>>>PYTHON-EXEC-OUTPUT
Error: Could not connect to runTestIdsPort: [Errno 60] Operation timed out
Error: Could not connect to runTestIdsPort
<<<PYTHON-EXEC-OUTPUT
This only happens when I set "python.experiments.optInto": ["pythonTestAdapter"]
in my settings.json
file; if I explicitly opt out of that experiment, this issue does not recur.
I am able to run tests in the terminal in the same environment (conda) using pytest
directly without issue.
Steps to reproduce:
- Enable
pythonTestAdapter
via"python.experiments.optInto": ["pythonTestAdapter"]
insettings.json
. - Try to run a simple test, like the following:
def test_test_setup():
assert 0 == 1
Diagnostic data
- Python version (& distribution if applicable, e.g. Anaconda): 3.10.12
- Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Conda
- Value of the
python.languageServer
setting: Default
Output for Python
in the Output
panel (View
→Output
, change the drop-down the upper-right of the Output
panel to Python
)
2023-10-18 11:23:46.371 [debug] Cached data exists KeyPrefix=Cache_Method_Output_b._selectIfLaunchedViaActivatedEnv-Args=true
2023-10-18 11:23:46.371 [debug] Found cached env for /Users/hh/mambaforge/envs/sci-ops-dev/bin/python
2023-10-18 11:23:46.371 [debug] Resolved /Users/hh/mambaforge/envs/sci-ops-dev/bin/python from cache: {"name":"sci-ops-dev","location":"/Users/hh/mambaforge/envs/sci-ops-dev","kind":"virt-conda","executable":{"filename":"/Users/hh/mambaforge/envs/sci-ops-dev/bin/python","sysPrefix":"/Users/hh/mambaforge","ctime":1697620700724,"mtime":1697620700724},"display":"Python 3.10.12 ('sci-ops-dev')","version":{"major":3,"minor":10,"micro":12,"release":{"level":"final","serial":0},"sysVersion":"3.10.12 | packaged by conda-forge | (main, Jun 23 2023, 22:39:40) [Clang 15.0.7 ]"},"arch":3,"distro":{"org":"Anaconda, Inc."},"source":[],"type":"Conda","id":"/Users/hh/mambaforge/envs/sci-ops-dev/bin/python","detailedDisplayName":"Python 3.10.12 ('sci-ops-dev': conda)"}
2023-10-18 11:23:46.376 [debug] Cached data exists KeyPrefix=Cache_Method_Output_b._selectIfLaunchedViaActivatedEnv-Args=true
2023-10-18 11:23:46.376 [debug] Found cached env for /Users/hh/mambaforge/envs/sci-ops-dev/bin/python
2023-10-18 11:23:46.376 [debug] Resolved /Users/hh/mambaforge/envs/sci-ops-dev/bin/python from cache: {"name":"sci-ops-dev","location":"/Users/hh/mambaforge/envs/sci-ops-dev","kind":"virt-conda","executable":{"filename":"/Users/hh/mambaforge/envs/sci-ops-dev/bin/python","sysPrefix":"/Users/hh/mambaforge","ctime":1697620700724,"mtime":1697620700724},"display":"Python 3.10.12 ('sci-ops-dev')","version":{"major":3,"minor":10,"micro":12,"release":{"level":"final","serial":0},"sysVersion":"3.10.12 | packaged by conda-forge | (main, Jun 23 2023, 22:39:40) [Clang 15.0.7 ]"},"arch":3,"distro":{"org":"Anaconda, Inc."},"source":[],"type":"Conda","id":"/Users/hh/mambaforge/envs/sci-ops-dev/bin/python","detailedDisplayName":"Python 3.10.12 ('sci-ops-dev': conda)"}
2023-10-18 11:23:46.381 [debug] Found cached env for /Users/hh/mambaforge/envs/sci-ops-dev/bin/python
2023-10-18 11:23:46.382 [debug] Resolved /Users/hh/mambaforge/envs/sci-ops-dev/bin/python from cache: {"name":"sci-ops-dev","location":"/Users/hh/mambaforge/envs/sci-ops-dev","kind":"virt-conda","executable":{"filename":"/Users/hh/mambaforge/envs/sci-ops-dev/bin/python","sysPrefix":"/Users/hh/mambaforge","ctime":1697620700724,"mtime":1697620700724},"display":"Python 3.10.12 ('sci-ops-dev')","version":{"major":3,"minor":10,"micro":12,"release":{"level":"final","serial":0},"sysVersion":"3.10.12 | packaged by conda-forge | (main, Jun 23 2023, 22:39:40) [Clang 15.0.7 ]"},"arch":3,"distro":{"org":"Anaconda, Inc."},"source":[],"type":"Conda","id":"/Users/hh/mambaforge/envs/sci-ops-dev/bin/python","detailedDisplayName":"Python 3.10.12 ('sci-ops-dev': conda)"}
2023-10-18 11:23:46.382 [debug] Cached data exists KeyPrefix=Cache_Method_Output_E.getCondaVersion-Args=
2023-10-18 11:23:46.384 [debug] Found executable within conda env {"name":"sci-ops-dev","prefix":"/Users/hh/mambaforge/envs/sci-ops-dev"}
2023-10-18 11:23:46.385 [info] Server listening on port 51826
2023-10-18 11:23:46.385 [debug] Server started for pytest test ids server and listening on port 51826
2023-10-18 11:23:46.392 [info] Running pytest with arguments: /Users/hh/.vscode/extensions/ms-python.python-2023.18.0/pythonFiles/vscode_pytest/run_pytest_script.py --rootdir /Users/hh/Documents/Pachama/sci-ops
2023-10-18 11:23:46.392 [info] > conda run -n sci-ops-dev --no-capture-output python ~/.vscode/extensions/ms-python.python-2023.18.0/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2023.18.0/pythonFiles/vscode_pytest/run_pytest_script.py --rootdir .
2023-10-18 11:23:46.392 [info] cwd: .
2023-10-18 11:23:46.441 [debug] Clearing context for python dependencies not installed: /Users/hh/Documents/Pachama/sci-ops/tests/unit/flyte/project_evaluation/tasks/test_evaluation.py
2023-10-18 11:23:48.902 [debug] Cached data exists KeyPrefix=Cache_Method_Output_b._selectIfLaunchedViaActivatedEnv-Args=true
2023-10-18 11:23:48.903 [debug] Found cached env for /Users/hh/mambaforge/envs/sci-ops-dev/bin/python
2023-10-18 11:23:48.903 [debug] Resolved /Users/hh/mambaforge/envs/sci-ops-dev/bin/python from cache: {"name":"sci-ops-dev","location":"/Users/hh/mambaforge/envs/sci-ops-dev","kind":"virt-conda","executable":{"filename":"/Users/hh/mambaforge/envs/sci-ops-dev/bin/python","sysPrefix":"/Users/hh/mambaforge","ctime":1697620700724,"mtime":1697620700724},"display":"Python 3.10.12 ('sci-ops-dev')","version":{"major":3,"minor":10,"micro":12,"release":{"level":"final","serial":0},"sysVersion":"3.10.12 | packaged by conda-forge | (main, Jun 23 2023, 22:39:40) [Clang 15.0.7 ]"},"arch":3,"distro":{"org":"Anaconda, Inc."},"source":[],"type":"Conda","id":"/Users/hh/mambaforge/envs/sci-ops-dev/bin/python","detailedDisplayName":"Python 3.10.12 ('sci-ops-dev': conda)"}
2023-10-18 11:23:48.913 [debug] Cached data exists KeyPrefix=Cache_Method_Output_b._selectIfLaunchedViaActivatedEnv-Args=true
2023-10-18 11:23:48.913 [debug] Clearing context for python dependencies not installed: ms-python.python.Python
2023-10-18 11:23:48.914 [debug] Found cached env for /Users/hh/mambaforge/envs/sci-ops-dev/bin/python
2023-10-18 11:23:48.914 [debug] Resolved /Users/hh/mambaforge/envs/sci-ops-dev/bin/python from cache: {"name":"sci-ops-dev","location":"/Users/hh/mambaforge/envs/sci-ops-dev","kind":"virt-conda","executable":{"filename":"/Users/hh/mambaforge/envs/sci-ops-dev/bin/python","sysPrefix":"/Users/hh/mambaforge","ctime":1697620700724,"mtime":1697620700724},"display":"Python 3.10.12 ('sci-ops-dev')","version":{"major":3,"minor":10,"micro":12,"release":{"level":"final","serial":0},"sysVersion":"3.10.12 | packaged by conda-forge | (main, Jun 23 2023, 22:39:40) [Clang 15.0.7 ]"},"arch":3,"distro":{"org":"Anaconda, Inc."},"source":[],"type":"Conda","id":"/Users/hh/mambaforge/envs/sci-ops-dev/bin/python","detailedDisplayName":"Python 3.10.12 ('sci-ops-dev': conda)"}
2023-10-18 11:23:48.914 [debug] Cached data exists KeyPrefix=Cache_Method_Output_E.ensureEnvironmentContainsPython-Args="/Users/hh/mambaforge/envs/sci-ops-dev/bin/python"-Arg-Separator-undefined
2023-10-18 11:23:48.954 [debug] Clearing context for python dependencies not installed: ms-python.python.Python
2023-10-18 11:24:06.185 [debug] Cached data exists KeyPrefix=Cache_Method_Output_b._selectIfLaunchedViaActivatedEnv-Args=true
2023-10-18 11:24:06.185 [debug] Clearing context for python dependencies not installed: /Users/hh/Documents/Pachama/sci-ops/tests/unit/flyte/project_evaluation/tasks/test_evaluation.py
2023-10-18 11:24:06.186 [debug] Found cached env for /Users/hh/mambaforge/envs/sci-ops-dev/bin/python
2023-10-18 11:24:06.186 [debug] Resolved /Users/hh/mambaforge/envs/sci-ops-dev/bin/python from cache: {"name":"sci-ops-dev","location":"/Users/hh/mambaforge/envs/sci-ops-dev","kind":"virt-conda","executable":{"filename":"/Users/hh/mambaforge/envs/sci-ops-dev/bin/python","sysPrefix":"/Users/hh/mambaforge","ctime":1697620700724,"mtime":1697620700724},"display":"Python 3.10.12 ('sci-ops-dev')","version":{"major":3,"minor":10,"micro":12,"release":{"level":"final","serial":0},"sysVersion":"3.10.12 | packaged by conda-forge | (main, Jun 23 2023, 22:39:40) [Clang 15.0.7 ]"},"arch":3,"distro":{"org":"Anaconda, Inc."},"source":[],"type":"Conda","id":"/Users/hh/mambaforge/envs/sci-ops-dev/bin/python","detailedDisplayName":"Python 3.10.12 ('sci-ops-dev': conda)"}
2023-10-18 11:24:06.186 [debug] Cached data exists KeyPrefix=Cache_Method_Output_E.ensureEnvironmentContainsPython-Args="/Users/hh/mambaforge/envs/sci-ops-dev/bin/python"-Arg-Separator-{"uri":{"$mid":1,"fsPath":"/Users/hh/Documents/Pachama/sci-ops","external":"file:///Users/hh/Documents/Pachama/sci-ops","path":"/Users/hh/Documents/Pachama/sci-ops","scheme":"file"},"name":"sci-ops","index":0}
2023-10-18 11:24:06.214 [debug] Cached data exists KeyPrefix=Cache_Method_Output_b._selectIfLaunchedViaActivatedEnv-Args=true
2023-10-18 11:24:06.214 [debug] Found cached env for /Users/hh/mambaforge/envs/sci-ops-dev/bin/python
2023-10-18 11:24:06.214 [debug] Resolved /Users/hh/mambaforge/envs/sci-ops-dev/bin/python from cache: {"name":"sci-ops-dev","location":"/Users/hh/mambaforge/envs/sci-ops-dev","kind":"virt-conda","executable":{"filename":"/Users/hh/mambaforge/envs/sci-ops-dev/bin/python","sysPrefix":"/Users/hh/mambaforge","ctime":1697620700724,"mtime":1697620700724},"display":"Python 3.10.12 ('sci-ops-dev')","version":{"major":3,"minor":10,"micro":12,"release":{"level":"final","serial":0},"sysVersion":"3.10.12 | packaged by conda-forge | (main, Jun 23 2023, 22:39:40) [Clang 15.0.7 ]"},"arch":3,"distro":{"org":"Anaconda, Inc."},"source":[],"type":"Conda","id":"/Users/hh/mambaforge/envs/sci-ops-dev/bin/python","detailedDisplayName":"Python 3.10.12 ('sci-ops-dev': conda)"}
2023-10-18 11:24:06.232 [debug] Clearing context for python dependencies not installed: /Users/hh/Documents/Pachama/sci-ops/tests/unit/flyte/project_evaluation/tasks/test_evaluation.py
2023-10-18 11:24:08.672 [debug] Cached data exists KeyPrefix=Cache_Method_Output_b._selectIfLaunchedViaActivatedEnv-Args=true
2023-10-18 11:24:08.673 [debug] Found cached env for /Users/hh/mambaforge/envs/sci-ops-dev/bin/python
2023-10-18 11:24:08.673 [debug] Resolved /Users/hh/mambaforge/envs/sci-ops-dev/bin/python from cache: {"name":"sci-ops-dev","location":"/Users/hh/mambaforge/envs/sci-ops-dev","kind":"virt-conda","executable":{"filename":"/Users/hh/mambaforge/envs/sci-ops-dev/bin/python","sysPrefix":"/Users/hh/mambaforge","ctime":1697620700724,"mtime":1697620700724},"display":"Python 3.10.12 ('sci-ops-dev')","version":{"major":3,"minor":10,"micro":12,"release":{"level":"final","serial":0},"sysVersion":"3.10.12 | packaged by conda-forge | (main, Jun 23 2023, 22:39:40) [Clang 15.0.7 ]"},"arch":3,"distro":{"org":"Anaconda, Inc."},"source":[],"type":"Conda","id":"/Users/hh/mambaforge/envs/sci-ops-dev/bin/python","detailedDisplayName":"Python 3.10.12 ('sci-ops-dev': conda)"}
2023-10-18 11:24:08.696 [debug] Clearing context for python dependencies not installed: /Users/hh/Documents/Pachama/sci-ops/tests/unit/flyte/project_evaluation/tasks/test_evaluation.py
2023-10-18 11:24:13.798 [debug] Test run finished, subprocess closed.
2023-10-18 11:24:24.465 [debug] Cached data exists KeyPrefix=Cache_Method_Output_b._selectIfLaunchedViaActivatedEnv-Args=true
2023-10-18 11:24:24.465 [debug] Clearing context for python dependencies not installed: ms-python.python.Python
2023-10-18 11:24:24.466 [debug] Found cached env for /Users/hh/mambaforge/envs/sci-ops-dev/bin/python
2023-10-18 11:24:24.466 [debug] Resolved /Users/hh/mambaforge/envs/sci-ops-dev/bin/python from cache: {"name":"sci-ops-dev","location":"/Users/hh/mambaforge/envs/sci-ops-dev","kind":"virt-conda","executable":{"filename":"/Users/hh/mambaforge/envs/sci-ops-dev/bin/python","sysPrefix":"/Users/hh/mambaforge","ctime":1697620700724,"mtime":1697620700724},"display":"Python 3.10.12 ('sci-ops-dev')","version":{"major":3,"minor":10,"micro":12,"release":{"level":"final","serial":0},"sysVersion":"3.10.12 | packaged by conda-forge | (main, Jun 23 2023, 22:39:40) [Clang 15.0.7 ]"},"arch":3,"distro":{"org":"Anaconda, Inc."},"source":[],"type":"Conda","id":"/Users/hh/mambaforge/envs/sci-ops-dev/bin/python","detailedDisplayName":"Python 3.10.12 ('sci-ops-dev': conda)"}
2023-10-18 11:24:24.466 [debug] Cached data exists KeyPrefix=Cache_Method_Output_E.ensureEnvironmentContainsPython-Args="/Users/hh/mambaforge/envs/sci-ops-dev/bin/python"-Arg-Separator-undefined
User Settings
envFile: "<placeholder>"
languageServer: "Pylance"
formatting
• provider: "none"
testing
• pytestArgs: "<placeholder>"
• pytestEnabled: true
• pytestPath: "<placeholder>"
experiments
• optInto: ["pythonTestAdapter"]
Extension version: 2023.18.0 VS Code version: Code 1.82.3 (fdb98833154679dbaa7af67a5a29fe19e55c2b73, 2023-10-02T11:06:17.496Z) OS version: Darwin x64 23.0.0 Modes:
System Info
Item | Value |
---|---|
CPUs | Intel® Core™ i7-1068NG7 CPU @ 2.30GHz (8 x 2300) |
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 video_decode: enabled video_encode: enabled vulkan: disabled_off webgl: enabled webgl2: enabled webgpu: enabled |
Load (avg) | 4, 4, 5 |
Memory (System) | 32.00GB (0.04GB free) |
Process Argv | –crash-reporter-id b3325bff-fe97-4602-b260-db680d47ed2b |
Screen Reader | no |
VM | 0% |
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
vserr242:30382549
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscod805cf:30301675
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593:30376534
pythonvs932:30410667
py29gd2263:30856252
vscaat:30438848
vsclangdc:30486549
c4g48928:30535728
dsvsc012cf:30540253
pynewext54:30695312
azure-dev_surveyone:30548225
2e4cg342:30602488
f6dab269:30613381
a9j8j154:30646983
showlangstatbar:30737416
a2ce3375:30757347
pythonfmttext:30731395
fixshowwlkth:30771522
showindicator:30805244
pythongtdpath:30769146
i26e3531:30792625
pythonnosmt12:30797651
pythonidxptcf:30805731
pythonnoceb:30805159
copilotsettingt:30859503
dsvsc013:30795093
dsvsc014:30804076
diffeditorv2:30821572
dsvsc015:30845448
pythontbext0:30864172
About this issue
- Original URL
- State: closed
- Created 8 months ago
- Comments: 17 (8 by maintainers)
@jcampbell05 and @danleesmith could you both send logs for the “python output logs” and “python” logs? Specifically with debugging set to trace.
@heidimhurst it is interesting because from your logs it is clear that there is a socket opened and the environment variable that passes the port number to the subprocess works correctly since you do not have the error message about a null value for the port variable. I can also see from your logs the server is started correctly here
Server started for pytest test ids server and listening on port 61687
so then that only leaves the subprocess unable to connect as the fault point. Let me talk with my coworkers more. ThanksLet me see if I can put in more in-depth error messaging to check if we got the right env var value to the subprocess that contains the port number. Ill reach out when I have a PR merged. Thanks!!