feat(testing): expose pytest marks as tags in Test Explorer#25740
Open
andravin wants to merge 4 commits intomicrosoft:mainfrom
Open
feat(testing): expose pytest marks as tags in Test Explorer#25740andravin wants to merge 4 commits intomicrosoft:mainfrom
andravin wants to merge 4 commits intomicrosoft:mainfrom
Conversation
Author
|
@microsoft-github-policy-service agree |
Author
Author
|
Tested with v2026.0.0 because main has build issues. As pictured in the above screenshot, I created test file with |
Author
|
For testers: A prebuilt VSIX is available at v2026.0.0-pytest-marks. Install with: code --install-extension ms-python-insiders.vsixIf 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.vsixNote: This replaces the official Python extension. Uninstall and reinstall from the marketplace to revert. |
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 <noreply@anthropic.com>
Prevents duplicate tags when the same marker is applied multiple times or through plugin interactions. Uses dict.fromkeys() to preserve order while deduplicating. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
67107ef to
97ffb96
Compare
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add TypeScript unit tests verifying populateTestTree correctly converts tags to TestTag objects with mark. prefix, and handles empty/undefined tags. Add Python discovery test verifying mark extraction, deduplication, parametrize filtering, and tag ordering. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Author
|
Tested against main. Unit tests have been added. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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:
Fixes #20350