Description
Behaviour
When using the Test Explorer with tests written with unittest and those tests are run in a separate process (following an os.fork()
), the first test is correctly run and the second one blocks undefinitely.
Steps to reproduce:
Minimal example of Python tests to reproduce the issue:
import unittest
import os
import time
import sys
class ForkedTestCase(unittest.TestCase):
def run(self, result=None):
pid = os.fork()
if pid == 0:
# Mecanics to communicate test results to the main process
# are omitted here
print(">>> run test case")
unittest.TestCase.run(self, result)
print(">>> test case end")
sys.exit(0)
else:
os.waitpid(pid, 0)
class MyTests(ForkedTestCase):
def test_me_please(self):
time.sleep(0.1)
print("Ohhhh yes!")
time.sleep(0.2)
assert True
def test_me_again(self):
time.sleep(0.2)
print("Ohhhh no!")
time.sleep(0.2)
assert False
def test_me_again_and_again(self):
time.sleep(0.3)
print("What ?!")
time.sleep(0.2)
assert True
if __name__ == "__main__":
unittest.main()
When launched from a console with e.g. python test.py
, tests are correctly run.
But from Test Explorer, a click on the "play" icon of the hole class (MyTests) will result in one test correctly run and others that stay unfinished. Note that individual run of each test works correctly.
Output example:
Received test ids from temp file.
>>> run test case
test_me_again (tests_xx.MyTests) ... Ohhhh no!
FAIL
>>> test case end
>>> run test case
test_me_again_and_again (tests_xx.MyTests) ... What ?!
ok
A ">>> test case end" is missing and the test blocks.
Diagnostic data
Output for Python
in the Output
panel (View
→Output
, change the drop-down the upper-right of the Output
panel to Python
)
XXX
Extension version: 2025.4.0
VS Code version: Code 1.97.2 (e54c774e0add60467559eb0d1e229c6452cf8447, 2025-02-12T23:20:35.343Z)
OS version: Linux x64 5.15.0-134-generic
Modes:
- Python version (& distribution if applicable, e.g. Anaconda): 3.10.12
- Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Global
- Value of the
python.languageServer
setting: Default
User Settings
envFile: "<placeholder>"
languageServer: "Pylance"
testing
• unittestArgs: "<placeholder>"
• unittestEnabled: true
experiments
• optOutFrom: ["pythonDiscoveryUsingWorkers"]
Installed Extensions
Extension Name | Extension Id | Version |
---|---|---|
autodocstring | njp | 0.6.1 |
black-formatter | ms- | 2025.2.0 |
cmake | twx | 0.0.17 |
cmake-tools | ms- | 1.20.53 |
copilot | Git | 1.277.0 |
copilot-chat | Git | 0.24.1 |
cpptools | ms- | 1.24.5 |
cpptools-extension-pack | ms- | 1.3.1 |
cpptools-themes | ms- | 2.0.0 |
debug | web | 0.27.0 |
debugpy | ms- | 2025.6.0 |
devdocs | dei | 0.2.0 |
docker | doc | 0.4.10 |
edit-with-shell | ryu | 1.3.0 |
git-graph | mhu | 1.30.0 |
gitblame | wad | 11.1.2 |
gitlab-workflow | Git | 6.11.0 |
go | gol | 0.46.1 |
hexeditor | ms- | 1.11.1 |
jenkinsfile-support | sec | 0.1.0 |
js-debug | ms- | 1.97.1 |
js-debug-companion | ms- | 1.1.3 |
json | Zai | 2.0.2 |
lldb-vscode | lan | 0.2.3 |
magit | kah | 0.6.66 |
markdown-all-in-one | yzh | 3.6.3 |
org-mode | too | 0.5.0 |
python | ms- | 2025.4.0 |
remote-containers | ms- | 0.401.0 |
remote-explorer | ms- | 0.4.3 |
remote-server | ms- | 1.5.2 |
remote-ssh | ms- | 0.119.0 |
remote-ssh-edit | ms- | 0.87.0 |
remote-wsl | ms- | 0.88.5 |
rest-client | hum | 0.25.1 |
rewrap | stk | 1.16.3 |
rust-analyzer | rus | 0.3.2433 |
swiper | wen | 2.1.2 |
test-adapter-converter | ms- | 0.2.1 |
vscode-docker | ms- | 1.29.5 |
vscode-groovy-lint | Nic | 3.3.1 |
vscode-highlight | fab | 1.9.0 |
vscode-js-profile-table | ms- | 1.0.10 |
vscode-kubernetes-tools | ms- | 1.3.20 |
vscode-lldb | vad | 1.11.4 |
vscode-pylance | ms- | 2025.4.1 |
vscode-remote-extensionpack | ms- | 0.26.0 |
vscode-test-explorer | hbe | 2.22.1 |
vscode-yaml | red | 1.17.0 |
System Info
Item | Value |
---|---|
CPUs | Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz (8 x 2812) |
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: disabled_software vulkan: disabled_off webgl: enabled webgl2: enabled webgpu: disabled_off webnn: disabled_off |
Load (avg) | 4, 3, 3 |
Memory (System) | 31.11GB (10.31GB free) |
Process Argv | . --crash-reporter-id e924368d-d11e-4156-ab9c-783e009058c9 |
Screen Reader | no |
VM | 3% |
DESKTOP_SESSION | cinnamon |
XDG_CURRENT_DESKTOP | X-Cinnamon |
XDG_SESSION_DESKTOP | cinnamon |
XDG_SESSION_TYPE | x11 |
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805:30301674
binariesv615:30325510
c4g48928:30535728
azure-dev_surveyone:30548225
a9j8j154:30646983
962ge761:30959799
h48ei257:31000450
pythontbext0:30879054
cppperfnew:31000557
dwnewjupytercf:31046870
pythonrstrctxt:31112756
nativeloc2:31192216
5fd0e150:31155592
dwcopilot:31170013
6074i472:31201624
dwoutputs:31242946
customenabled:31248079
9064b325:31222308
copilot_t_ci:31222730
f5992895:31277799
pythoneinst12:31285622
bgtreat:31268568
4gafe986:31271826
563cc122:31253270
31787653:31262186
3e8i5726:31271747
0339e702:31259951
996jf627:31283433
usemplatestapi:31288272
7bj51361:31289155
aj496949:31278748
aj953862:31281341
generatesymbolc:31292703
convertfstringc:31292702
gendocf:31292707