Skip to content

Cancelling tests in the "Debug Test" mode doesn't trigger pytest's fixtures teardowns (after yield). #24847

@ivan-toriya-precis

Description

@ivan-toriya-precis

Type: Bug

Behaviour

Cancelling tests in the "Debug Test" mode doesn't trigger pytest's fixtures teardowns.

Is it an expected behavior or a bug?

Steps to reproduce:

  1. Add a breakpoint after the fixture (with teardown using yield) is created.
  2. "Testing" > "Debug Test"
  3. "Cancel Tests"
  4. Code after yield didn't run.

Diagnostic data

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

2025-02-25 14:45:17.144 [info] > . ./.venv/bin/activate && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python ~/.vscode/extensions/ms-python.python-2025.0.0-linux-x64/python_files/printEnvVariables.py
2025-02-25 14:45:17.144 [info] shell: bash
2025-02-25 14:45:17.167 [info] arg: --rootdir already exists in args, not adding.
2025-02-25 14:45:17.167 [info] Attempting to use temp directory for test ids file, file name: test-ids-caf36d75b8dbfc64a567.txt
2025-02-25 14:45:17.167 [info] All environment variables set for pytest execution: {"ATUIN_PREEXEC_BACKEND":"1:none","ATUIN_SESSION":"01953d507ebe7d5284e0eb1d23525314","CHROME_DESKTOP":"code.desktop","DBUS_SESSION_BUS_ADDRESS":"unix:path=/run/user/1000/bus","DESKTOP_SESSION":"gnome","DISPLAY":":0","GDK_BACKEND":"x11","GDMSESSION":"gnome","GDM_LANG":"en_US.UTF-8","GEM_HOME":"/home/ivan/gems","GIO_LAUNCHED_DESKTOP_FILE":"/usr/share/applications/code.desktop","GIO_LAUNCHED_DESKTOP_FILE_PID":"59229","GJS_DEBUG_OUTPUT":"stderr","GJS_DEBUG_TOPICS":"JS ERROR;JS LOG","GNOME_DESKTOP_SESSION_ID":"this-is-deprecated","GNOME_SETUP_DISPLAY":":1","GTK_MODULES":"gail:atk-bridge","HOME":"/home/ivan","IM_CONFIG_CHECK_ENV":"1","IM_CONFIG_PHASE":"1","INVOCATION_ID":"fdb9f9b85c3a4d56b117307695547d27","JOURNAL_STREAM":"8:28608","LANG":"en_US.UTF-8","LANGUAGE":"en_US:en","LOGNAME":"ivan","MANAGERPID":"2346","ORIGINAL_XDG_CURRENT_DESKTOP":"GNOME","PWD":"/home/ivan","QTWEBENGINE_DICTIONARIES_PATH":"/usr/share/hunspell-bdic/","QT_ACCESSIBILITY":"1","QT_IM_MODULE":"ibus","SESSION_MANAGER":"local/ideapad:@/tmp/.ICE-unix/2547,unix/ideapad:/tmp/.ICE-unix/2547","SHELL":"/usr/bin/bash","SHLVL":"0","SSH_AGENT_LAUNCHER":"openssh","SSH_AUTH_SOCK":"/run/user/1000/keyring/ssh","STARSHIP_SESSION_KEY":"1826326933438114","STARSHIP_SHELL":"bash","SYSTEMD_EXEC_PID":"2610","USER":"ivan","USERNAME":"ivan","VSCODE_CODE_CACHE_PATH":"/home/ivan/.config/Code/CachedData/e54c774e0add60467559eb0d1e229c6452cf8447","VSCODE_CRASH_REPORTER_PROCESS_TYPE":"extensionHost","VSCODE_CWD":"/home/ivan","VSCODE_ESM_ENTRYPOINT":"vs/workbench/api/node/extensionHostProcess","VSCODE_HANDLES_UNCAUGHT_ERRORS":"true","VSCODE_IPC_HOOK":"/run/user/1000/vscode-c6d150be-1.97-main.sock","VSCODE_NLS_CONFIG":"{\"userLocale\":\"en-us\",\"osLocale\":\"en-us\",\"resolvedLanguage\":\"en\",\"defaultMessagesFile\":\"/usr/share/code/resources/app/out/nls.messages.json\",\"locale\":\"en-us\",\"availableLanguages\":{}}","VSCODE_PID":"59229","WAYLAND_DISPLAY":"wayland-0","XAUTHORITY":"/run/user/1000/.mutter-Xwaylandauth.8WDE22","XDG_CURRENT_DESKTOP":"GNOME","XDG_DATA_DIRS":"/usr/share/gnome:/home/ivan/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share/:/usr/share/","XDG_MENU_PREFIX":"gnome-","XDG_RUNTIME_DIR":"/run/user/1000","XDG_SESSION_CLASS":"user","XDG_SESSION_DESKTOP":"gnome","XDG_SESSION_TYPE":"wayland","XMODIFIERS":"@im=ibus","_":"/usr/share/code/code","ELECTRON_RUN_AS_NODE":"1","VSCODE_L10N_BUNDLE_LOCATION":"","PATH":"/home/ivan/.local/bin:/home/ivan/gems/bin:/home/ivan/.atuin/bin:/home/ivan/.cargo/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/opt/nvim-linux64/bin:/usr/local/go/bin","PYTHONPATH":"/home/ivan/.vscode/extensions/ms-python.python-2025.0.0-linux-x64/python_files","TEST_RUN_PIPE":"/run/user/1000/python-test-results-7228f1b7581040c34747","RUN_TEST_IDS_PIPE":"/tmp/test-ids-caf36d75b8dbfc64a567.txt"}
2025-02-25 14:45:17.168 [info] Running DEBUG pytest with arguments: --color=yes,--rootdir=/home/ivan/myworkingdir,--capture=no for workspace /home/ivan/myworkingdir 

2025-02-25 14:45:17.168 [info] Using configuration in launch.json
2025-02-25 14:45:44.953 [info] Test Result named pipe /run/user/1000/python-test-results-7228f1b7581040c34747  cancelled
2025-02-25 14:45:44.954 [info] Test run cancelled, resolving 'TillServerClose' deferred for /home/ivan/myworkingdir.

Extension version: 2025.0.0
VS Code version: Code 1.97.2 (e54c774e0add60467559eb0d1e229c6452cf8447, 2025-02-12T23:20:35.343Z)
OS version: Linux x64 6.1.0-31-amd64
Modes:

  • 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
User Settings


languageServer: "Pylance"

testing
• pytestArgs: "<placeholder>"
• pytestEnabled: true

terminal
• executeInFileDir: "<placeholder>"

Installed Extensions
Extension Name Extension Id Version
code-spell-checker str 4.0.39
copilot Git 1.275.0
copilot-chat Git 0.24.1
copy Pra 1.1.1
cron-explained tum 1.3.1
cucumberautocomplete ale 3.0.5
dark-modern-darker Dar 1.0.1
debugpy ms- 2025.0.1
EditorConfig Edi 0.17.1
even-better-toml tam 0.21.2
jinjahtml sam 0.20.0
js-debug ms- 1.97.1
material-icon-theme PKi 5.19.0
python ms- 2025.0.0
rainbow-csv mec 3.17.0
ruff cha 2025.10.0
simple-rst tro 1.5.4
terraform has 2.34.3
themeswitch Foo 1.0.5
vscode-docker ms- 1.29.4
vscode-js-profile-table ms- 1.0.10
vscode-pull-request-github Git 0.104.1
vscode-pylance ms- 2025.2.1
vscode-yaml red 1.16.0
System Info
Item Value
CPUs AMD Ryzen 5 4500U with Radeon Graphics (6 x 3991)
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) 1, 1, 1
Memory (System) 14.99GB (3.48GB free)
Process Argv --crash-reporter-id 84d87159-0a2b-4570-a260-abd9dc8b402e
Screen Reader no
VM 0%
DESKTOP_SESSION gnome
XDG_CURRENT_DESKTOP GNOME
XDG_SESSION_DESKTOP gnome
XDG_SESSION_TYPE wayland
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805cf:30301675
binariesv615:30325510
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyone:30548225
a9j8j154:30646983
962ge761:30959799
2e7ec940:31000449
pythontbext0:30879054
cppperfnew:31000557
dwnewjupytercf:31046870
nativerepl1:31139838
pythonrstrctxt:31112756
nativeloc2:31192216
iacca1:31171482
5fd0e150:31155592
dwcopilot:31170013
stablechunks:31184530
6074i472:31201624
dwoutputs:31242946
customenabled:31241370
hdaa2157:31222309
copilot_t_ci:31222730
jda6j935:31233686
copilothoveron:31245428

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions