What is the preferred way for editors/tools to interact with pytest? #8458
-
We are just starting floating the idea around of rewriting out testing support code for the Python extension for VS Code. As such that means making we hook into pytest appropriately. So my question is what does "appropriate" hooking look like to the pytest team? I.e. what is the preferred mechanism for test discovery (e.g. populate a test explorer), and to execute a test(s) (e.g. when a user runs a test from a test explorer)? And for whatever the answer is, what versions of pytest would be supported (I'm honestly more concerned to know this to tell people what they would need to upgrade to instead of requiring something like Python 2 support)? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Here a sparse version, i hope i find time to elaborate later An ide probably best integrates into pytest by having a pythonpath injected starter library that runs pytest.main with a own plugin object added This in turn can take actual full control over whatever pytest does I strongly recommend keeping us in the loop about apis /internals used I would recommend reasonably recent pytest But i suspect for part of the use cases it can easily work with 4.x I strongly recommend 6.x as starting point and choose lower versions only if absolutely required |
Beta Was this translation helpful? Give feedback.
-
Hello, sorry for intruding in the discussion but I have been working on something that could fit your need: https://github.com/Lothiraldan/litf. It is meant to be something similar to https://microsoft.github.io/language-server-protocol/. I already have a pytest plugin for it that seems to work so far but likely requires more work: https://github.com/Lothiraldan/pytest-litf For example if you install pytest and pytest-litf (pip install pytest pytest-litf) and run the following commands inside the directory https://github.com/Lothiraldan/pytest-litf/tree/master/example_dir, you will get:
And without the collect only:
From there, you can use the
Or whole files:
The protocol and plugin are open-source. I hope my effort could help reducing the maintenance cost between the test libraries and outside tools. |
Beta Was this translation helpful? Give feedback.
Here a sparse version, i hope i find time to elaborate later
An ide probably best integrates into pytest by having a pythonpath injected starter library that runs pytest.main with a own plugin object added
This in turn can take actual full control over whatever pytest does
I strongly recommend keeping us in the loop about apis /internals used
I would recommend reasonably recent pytest
But i suspect for part of the use cases it can easily work with 4.x
I strongly recommend 6.x as starting point and choose lower versions only if absolutely required