kondratyev-nv / vscode-python-test-adapter

Python Test Adapter for the VS Code Test Explorer
https://marketplace.visualstudio.com/items?itemName=LittleFoxTeam.vscode-python-test-adapter
MIT License
117 stars 27 forks source link

Feature request: Filter tests by pytest marker #286

Open LiamDeaconAntarcticaAM opened 1 year ago

LiamDeaconAntarcticaAM commented 1 year ago

I love this extension, but it would be truly awesome to be able to filter (and then run) tests within the Test Explorer side pane based on the pytest marker that tests have been annotated with 🚀

image

Quick idea would be to extend the @tag functionality with something like @pytest:<marker> .

A list of known (i.e. registered) markers could be scanned for within the config files that pytest itself lists. Alternatively the information can be gathered from pytest itself via pytest --markers, e.g.

$ pytest --markers | grep -E '^@pytest.mark.' | grep -Ev '^@pytest.mark.[a-z]+\('
@pytest.mark.unittest: mark as an isolated unit test
@pytest.mark.integration: mark as an integration test
@pytest.mark.django: mark as requiring django
@pytest.mark.slow: mark as a slow-running test
@pytest.mark.no_cover: disable coverage for this test.
@pytest.mark.tryfirst: mark a hook implementation function such that the plugin machinery will try to call it first/as early as possible.
@pytest.mark.trylast: mark a hook implementation function such that the plugin machinery will try to call it last/as late as possible.

What would need to be done to make this happen?