Skip to content

Conversation

@andravin
Copy link

Extract pytest marks (e.g., @pytest.mark.slow, @pytest.mark.integration) during test discovery and expose them as VS Code TestTags with IDs like "mark.slow", "mark.integration". This enables filtering tests by marks in the Test Explorer UI using @python-tests:mark.slow syntax.

Changes:

  • Add tags field to TestItem TypedDict in pytest plugin
  • Extract marks from test_case.own_markers in create_test_node()
  • Add tags field to DiscoveredTestItem TypeScript type
  • Create TestTag objects from marks in populateTestTree()

Fixes #20350

Extract pytest marks (e.g., @pytest.mark.slow, @pytest.mark.integration)
during test discovery and expose them as VS Code TestTags with IDs like
"mark.slow", "mark.integration". This enables filtering tests by
marks in the Test Explorer UI using @python-tests:mark.slow syntax.

Changes:
- Add tags field to TestItem TypedDict in pytest plugin
- Extract marks from test_case.own_markers in create_test_node()
- Add tags field to DiscoveredTestItem TypeScript type
- Create TestTag objects from marks in populateTestTree()

Fixes microsoft#20350

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@andravin
Copy link
Author

@microsoft-github-policy-service agree

@andravin
Copy link
Author

image

@andravin
Copy link
Author

Tested with v2026.0.0 because main has build issues.

As pictured in the above screenshot, I created test file with @pytest.mark.integration, @pytest.mark.slow, etc, and these appeared in the TEST EXPLORER filter as @python-tests:mark.integration, @python-tests:mark.slow, etc.

@andravin
Copy link
Author

For testers: A prebuilt VSIX is available at v2026.0.0-pytest-marks.

Install with:

code --install-extension ms-python-insiders.vsix

If you prefer to build from source:

git clone https://github.com/andravin/vscode-python.git
cd vscode-python
git checkout feature/pytest-marks-as-tags-release
npm install && npm run package
code --install-extension ms-python-insiders.vsix

Note: This replaces the official Python extension. Uninstall and reinstall from the marketplace to revert.

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