Skip to content

CPU Usage with Pytest #12052

@Ed1123

Description

@Ed1123

My problem is exactly the same as the one below, but I think the error triggers even though there no test intended in the current python file. For example if I open a simple python file without any if __name__ == "__main__": section I ended with that 30% CPU usage of Python inside VSCode.

When I open up VSCode in one of my projects cpu usage goes to 80%+ while it continually shows "Discovering Tests" in the lower bar.
I have configured 'pytest'.
Python version 3.7.3

Edit:
It seems that pytest found a "debug" file without a if __name__ == "__main__": and ran it (my bad) during discovery. That caused the high CPU usage and pytest did not finish running it but it was not apparent that pytest was currently running that file in the first place. As no error message is printed to Python Test log when canceling Test Discovery I did not get prompted with an error message saying something like "execution stopped in file xxxx.py" which would have pointed me to the culprit. I only discovered this while manually running pytest from the console.
I suggest that the error message that arises from stopping pytest prematurely should be logged somewhere within vscode.

Version: 1.33.1 (user setup)
Commit: 51b0b28134d51361cf996d2f0a1c698247aeabd8
Date: 2019-04-11T08:27:14.102Z
Electron: 3.1.6
Chrome: 66.0.3359.181
Node.js: 10.2.0
V8: 6.6.346.32
OS: Windows_NT x64 10.0.17763

Originally posted by @sleighsoft in #3724 (comment)

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bug

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions