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

Improvement suggestion : Display path different from real path #311

Open PicouAymeric opened 1 month ago

PicouAymeric commented 1 month ago

In my pytest plugin, I generate a lot of tests on the same test function / same class / same module. Using pytest hook pytest_generate_tests In order to be able to to run just a subset of my tests I would like to create virtual subset of my tests eventhough they are in the end running the same test function.

The idea would be to create a pytest_pycollect_makeitem hook function in my plugin to set a display prop on all my test different from nodeid

    def pytest_pycollect_makeitem(self, collector, name, obj):
        report = yield
        items = report.get_result()
        new_results = []
        for item in items:
            item.display = [display path depending on the test]
            new_results.append(item)
        return new_results

Then in Vscode testing tab I would have the display prop displayed instead of nodeid, but if we run that test it still runs the nodeid test. I previously could hack the default vscode implementation, but obviously it broke at the first vscode update because it wasn't meant to do that.

Do you think it would be possible to differentiate the test path displayed and the test path executed?