Skip to content

feat(testing): expose pytest marks as tags in Test Explorer - #26259

Open
Srikanth Palutla (sripal2013) wants to merge 1 commit into
microsoft:mainfrom
sripal2013:python-20350-pytest-marks-filter
Open

Srikanth Palutla (sripal2013) wants to merge 1 commit into
microsoft:mainfrom
sripal2013:python-20350-pytest-marks-filter

Conversation

@sripal2013

Copy link
Copy Markdown

Fixes #20350

This exposes pytest marks as VS Code TestTags so tests can be filtered
by mark in the Test Explorer (e.g. @python-tests:mark.slow).

Changes

  • Test discovery (vscode_pytest): TestItem now carries a tags list,
    extracted from test_case.own_markers, deduplicated in discovery
    order. The parametrize marker is excluded since it describes
    parameterization, not a user mark.
  • Test controller: DiscoveredTestItem accepts optional tags, and
    populateTestTree maps them to mark. tags alongside the
    existing run/debug tags. Adapters that don't report marks are
    unaffected.
  • Tests: new test_marks.py fixture (single, multiple, duplicate,
    parametrized, and unmarked cases), a discovery test asserting the
    tags payload, and two new populateTestTree unit tests.

Extract pytest marks during test discovery and expose them as VS Code TestTags (mark.<name>), so tests can be filtered by mark in the Test Explorer (e.g. @python-tests:mark.slow). Marks are deduplicated preserving discovery order, and the parametrize marker is excluded. Items from adapters that do not report marks keep only the default run/debug tags.

Fixes microsoft#20350
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add filter based on pytest marks to Test Explorer

1 participant