Skip to content

Test runs ignore TestRunRequest.exclude (filtered tests still run) #25742

@andravin

Description

@andravin

Type: Bug

Behaviour

When running tests from the VS Code Testing UI with a filter applied (or other scenarios where VS Code provides an exclude list), the Python extension ignores TestRunRequest.exclude. As a result, tests that VS Code explicitly excludes (commonly via Testing view filtering / “run visible tests”) still execute.

Expected behavior is that the extension honors TestRunRequest.exclude, excluding those items and their descendants per the VS Code Testing API contract. This appears to be the same underlying issue as #16929, which was closed but remains broken in early 2026.

Steps to reproduce:

  1. Open a workspace with multiple tests (pytest or unittest).
  2. In the VS Code Testing view, apply a filter so only a subset of tests is shown.
  3. Click Run Tests.
  4. Observe that tests outside the filtered set still execute.

Diagnostic data

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


N/A - this is a deterministic test selection bug: VS Code passes include/exclude lists to the extension in TestRunRequest, but the extension currently ignores request.exclude when constructing the run list (including descendants). Happy to provide logs if maintainers want them, but there are no errors emitted in the Python output panel for this scenario.

Extension version: 2026.1.2026011501
VS Code version: Code 1.107.1 (994fd12f8d3a5aa16f17d42c041e5809167e845a, 2025-12-17T14:15:14.850Z)
OS version: Linux x64 6.8.0-90-generic snap
Modes:

  • Python version (& distribution if applicable, e.g. Anaconda): 3.10.12
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Venv
  • Value of the python.languageServer setting: Default
User Settings


languageServer: "Pylance"

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

Installed Extensions
Extension Name Extension Id Version
arrange-selection Wup 1.3.1
black-formatter ms- 2025.2.0
cmake twx 0.0.17
cmake-tools ms- 1.21.36
copilot-chat Git 0.35.3
cpptools ms- 1.30.1
cpptools-extension-pack ms- 1.3.1
cpptools-themes ms- 2.0.0
debugpy ms- 2025.18.0
EditorConfig Edi 0.17.4
even-better-toml tam 0.21.2
gitlens eam 17.9.0
js-debug ms- 1.105.0
js-debug-companion ms- 1.1.3
jupyter ms- 2025.9.1
jupyter-keymap ms- 1.1.2
jupyter-renderers ms- 1.3.0
nsight-vscode-edition nvi 2025.1.36067579
prettier-vscode esb 12.1.1
pylint ms- 2025.2.0
python ms- 2026.1.2026011501
remote-containers ms- 0.437.0
sort-lines-by-selection ear 1.2.0
vscode-containers ms- 2.3.0
vscode-cython ktn 1.0.3
vscode-eslint dba 3.0.20
vscode-github-actions git 0.29.1
vscode-js-profile-flame ms- 1.0.9
vscode-js-profile-table ms- 1.0.10
vscode-jupyter-cell-tags ms- 0.1.9
vscode-jupyter-slideshow ms- 0.1.6
vscode-markdownlint Dav 0.61.1
vscode-pylance ms- 2025.10.4
vscode-python-envs ms- 1.17.10151017
System Info
Item Value
CPUs Intel(R) Xeon(R) Silver 4216 CPU @ 2.10GHz (32 x 800)
GPU Status 2d_canvas: enabled
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
trees_in_viz: disabled_off
video_decode: enabled
video_encode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
webnn: disabled_off
Load (avg) 3, 2, 1
Memory (System) 187.36GB (180.59GB free)
Process Argv --no-sandbox --force-user-env --ozone-platform=x11 --crash-reporter-id 627b27e5-8ac6-490e-85f7-777399b797a5
Screen Reader no
VM 0%
DESKTOP_SESSION ubuntu
XDG_CURRENT_DESKTOP ubuntu:GNOME
XDG_SESSION_DESKTOP ubuntu
XDG_SESSION_TYPE x11
A/B Experiments
vsliv368cf:30146710
binariesv615:30325510
nativeloc1:31344060
dwcopilot:31170013
dwoutputs:31242946
copilot_t_ci:31333650
e5gg6876:31282496
pythonrdcb7:31342333
6518g693:31436602
aj953862:31281341
63221493:31336333
envsdeactivate2:31353495
cloudbuttont:31379625
3efgi100_wstrepl:31403338
use-responses-api:31390855
defaultusage:31403421
je187915:31401257
ec5jj548:31422691
cmp-ext-treat:31426748
cp_cls_c_966_ss:31446431
c0683394:31419495
ge8j1254_inline_auto_hint_haiku:31431912
nes-autoexp-10:31446583
a5gib710:31434435
38bie571_auto:31440726
rename_enabled:31436409
7a04d226_do_not_restore_last_panel_session:31438103
anthropic_thinking_t:31432745
preserve_tokens:31444547
cp_cls_c_1081:31443829
copilot-nes-oct-trt:31432596
nes-jump-on-with-edit:31444032
nes-slash-models-on:31441832
nes-set-to-on:31441941
a43f0576c:31442824
nes-conv-1-3:31447850

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage-neededNeeds assignment to the proper sub-team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions