-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pytest: Display path different from real path #23351
Comments
Hi! Thanks for your detailed explanation! Are you able to use pytest parameterization or investigate any external plugins? We pass the testids in payloads between the python extension and the python subprocess. Therefore if the payloads sent to the python extension process display names and those are different from the run_ids which we use to signal which test runs. Do you want more info on how we get the display names and run_ids to see if something could be done there? |
I have tried for a while to find a way to change display path without having to edit the python extension but I didn't find anything that works properly. If you have some examples of plugin doing that, that would interrest me! However current implementation is closely linked to the folder structure: a test inside a class inside a module inside a folder. I ll try to overwrite that and build a tree only from a display property |
so pytest parameterized tests allows for test renaming like so:
but I think this is probably hacky and not right in your situation. Let me give it some more thought |
Looking more I actually think your original idea was correct, you should be able to add your own hooks and have that work within the scope of the extension. Pytest has specific measures to allow hooks to interact and so this should work. If you look the plugin you can see the test tree is build from the hook |
Hi, If that information was given using the session for example I could find a hack to override it, but since it is transmitted outside the pytest process I don't see any way of overwritting the tree |
Reading again your comments, I think maybe my needs weren't as clear as I thought: |
thank you for clarifying! If you just wanted to update the display but not actual I think those are too interconnected for this to maybe be possible in the current setup. The path of the test is used during build for both the path variable and the name and there would be no way for a separate plugin to make a change to the display path without changing the actual path the test goes to. I will leave this as a feature request then and if it gets enough support we can discuss how this could be incorporated. Thanks! |
Thanks for the feature request! We are going to give the community 60 days from when this issue was created to provide 7 👍 upvotes on the opening comment to gauge general interest in this idea. If there's enough upvotes then we will consider this feature request in our future planning. If there's unfortunately not enough upvotes then we will close this issue. |
Thank you for submitting your feature request and everyone who considered it! Unfortunately, this issue did not receive enough votes over the allotted time, and so we are closing the issue. |
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 adisplay prop
on all my test different fromnodeid
Then in Vscode testing tab I would have the
display
prop displayed instead ofnodeid
, but if we run that test it still runs thenodeid
test.In a previous version of Vscode I found a hack by changing fspath and _nodeid of my test then force session.config.args to my actual test module in pytest_collection, but this broke after a vscode upate (I kind of expected it to break someday)
Do you think it would be possible to differentiate the test path displayed and the test path executed?
The text was updated successfully, but these errors were encountered: