-
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
Discover PyTest tests only when necessary #1490
Comments
@logstar the code resides in https://github.com/Microsoft/vscode-python/tree/master/src/client/unittests/pytest/services where you can find the commands we are using and how we parse the output. We could probably stand to be smarter about how we refresh the test discovery mechanism. |
@brettcannon Thank you for your attention to this issue and the pointer to the test discovery service. After exploring the repository for a while, I think I will not be able to help on this issue. Just for learning purpose, I was wondering if you could briefly explain how a test discovery service is triggered after saving a test file. |
We add a callback for when a document gets saved onDidSaveTextDocument The handler onDocumentSaved is what triggers the test discovery. |
@DonJayamanne Thank you for your explanation! Just paste here some additional references for anyone who is also interested: VS code api: https://code.visualstudio.com/docs/extensionAPI/vscode-api . The event Overview of VS code extension api: https://code.visualstudio.com/docs/extensionAPI/vscode-api |
Providing a feature to disable automatic test discovery seems reasonable. |
This was implemented in the latest release: https://github.com/Microsoft/vscode-python/blob/master/CHANGELOG.md#enhancements |
Environment data
Actual behavior
Test discovery automatically runs after saving edits of a test file.
Although this behavior sounds natural, it causes a spike of energy consumption on every save of an edited test file. One might just want to save it without intending to run test immediately afterwards, e.g. for linting. The fan of my computer starts howling after a few saves.
In OSX activity monitor, energy impact changes from ~1 to ~50 after saving an edited test file, and the energy impact stays around 50 for about 3 seconds. I have 22 tests in the file I saved and 245 tests in total.
Related to issue #1474 and #1132.
Expected behavior
Only run test discovery after giving a command to run or clicking
Run Test
orDebug Test
.Steps to reproduce:
Logs
Output for
Python
in theOutput
panel (View
→Output
, change the drop-down the upper-right of theOutput
panel toPython
)Output from
Console
under theDeveloper Tools
panel (toggle Developer Tools on underHelp
)Question
Any pointer on how test discovery works in
vscode-python
?The text was updated successfully, but these errors were encountered: