Skip to content

pytest test discovery does not run #25748

@cdeil

Description

@cdeil

Type: Bug

Summary

Pytest gutter icons (play buttons) are missing after VS Code starts. Test discovery does not run automatically even though python.testing.pytestEnabled is true.

Workaround: Running Test: Refresh Tests from Command Palette fixes the issue until VS Code restarts.

Steps to Reproduce

  1. Open a Python project with pytest configured
  2. Ensure .vscode/settings.json has:
    {
      "python.testing.pytestArgs": ["tests"],
      "python.testing.unittestEnabled": false,
      "python.testing.pytestEnabled": true
    }
  3. Close and restart VS Code
  4. Open a test file (e.g., test_stock.py)
  5. Expected: Green play button icons appear next to test functions
  6. Actual: No gutter icons, Test Explorer is empty

Workaround

Run Test: Refresh Tests from Command Palette → Icons appear and tests work.

Note: Developer: Reload Window does NOT fix the issue.

Environment

  • VS Code: 1.108.2
  • OS: macOS arm64 (Darwin 25.2.0)
  • Python: 3.14.0
  • pytest: 9.0.2
  • ms-python.python: 2026.0.0

Log Evidence

Python.log shows no test discovery on startup:

[info] Active interpreter: .venv/bin/python
[info] Starting Pylance language server.
[error] Unable to find workspace for given file

After running Test: Refresh Tests, the log shows:

[info] Environment variables set for pytest discovery: PYTHONPATH=...
[info] Started pytest discovery subprocess for workspace ...
[info] Pytest discovery completed

Additional Context

  • Single window scenario (not multi-window)
  • pytest works fine from terminal: python -m pytest --collect-only succeeds
  • Python environment is correctly detected

Extension version: 2026.0.0
VS Code version: Code 1.108.2 (Universal) (c9d77990917f3102ada88be140d28b038d1dd7c7, 2026-01-21T13:52:09.270Z)
OS version: Darwin arm64 25.2.0
Modes:

System Info
Item Value
CPUs Apple M3 (8 x 2400)
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: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) 2, 2, 2
Memory (System) 16.00GB (0.11GB free)
Process Argv --crash-reporter-id ea819cd1-e9b8-4654-b394-6ba9979e300c
Screen Reader no
VM 0%
A/B Experiments
vsliv368:30146709
vswsl492:30256859
binariesv615:30325510
nativeloc1:31344060
dwcopilot:31170013
dwoutputs:31242946
copilot_t_ci:31333650
e5gg6876:31282496
pythonrdcb7:31342333
6518g693:31436602
aj953862:31281341
6abeh943:31336334
envsdeactivate2:31353495
cloudbuttont:31379625
42190218_ostrepl:31403339
use-responses-api:31390855
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
5j92g670_sonnet:31446810
rename_enabled:31436409
7a04d226_do_not_restore_last_panel_session:31438103
anthropic_thinking_t:31432745
h0hdh950:31428394
cp_cls_t_1081:31443828
copilot-nes-oct-trt:31432596
ia-use-proxy-models-svc:31450090
nes-jump-on-with-edit:31450417
nes-slash-models-on:31441832
core-renderer-profiling-on:31440367
nes-set-to-on:31441941
a43f0574a:31442826
ts_provider_disabled:31446105
c0ci8992_validated:31449878
nes-conv-2-3:31447852

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