-
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
python.testing.pytestArgs: passing config file path when it's in a subfolder consumes 100% of a CPU #23411
Comments
Hello! Thanks for this detailed bug report, I will investigate. Could you include your logs from the Also are you running the command yourself from the root of the repo right? Finally are you able to see the same behavior for an arbitrary test- ie if you just write a pytest test which always passes and run with the config arg do you get the same behavior? Sorry for all the questions! Thanks |
Thanks a lot for your help!
Sure. Note that I don't even run the tests, I only try to "collect" them (refreshing them in the Testing tab). Trace logs:
The logs hang at
No, I'm not running anything myself: it's vscode-python which runs the pytest process to collect the tests. I can trigger it by clicking on the "Refresh tests" button in the "Testing" tab.
Yep, I reproduced this in a clean, minimal project: % tree -a -L 2
.
├── config
│ ├── .pytest_cache
│ └── pytest.ini
├── tests
│ ├── __pycache__
│ └── test_hello.py
├── .venv
│ ├── bin
│ ├── CACHEDIR.TAG
│ ├── .gitignore
│ ├── lib
│ ├── .lock
│ └── pyvenv.cfg
└── .vscode
└── settings.json
9 directories, 7 files % cat .vscode/settings.json
{
"files.watcherExclude": {
"**/.venv*/**": true,
"**/venv*/**": true
},
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"python.testing.pytestArgs": [
"--config-file=config/pytest.ini"
]
} % cat config/pytest.ini
[pytest]
python_files =
test_*.py
testpaths =
tests % cat tests/test_hello.py
def test_hello():
assert True Running the pytest command myself works fine: % ./.venv/bin/python -m pytest --collect-only --config-file=config/pytest.ini
==== test session starts ====
platform linux -- Python 3.12.1, pytest-8.2.0, pluggy-1.5.0
rootdir: /tmp/repro23411/config
configfile: pytest.ini
collected 1 item
<Dir repro23411>
<Dir tests>
<Module test_hello.py>
<Function test_hello>
==== 1 test collected in 0.01s ==== |
Hello! I have found the issue here. One thing I do to build the test tree seen in the test explorer is create nodes between session node (root) and test nodes. In this instance you can see in your logs that the root is within the config folder |
That's awesome, thank you so much! Take all the time you need, no worries 😄 And thanks for the explanation, that makes total sense 🙂 |
Hi! This is merged and will be out on vscode insiders tomorrow so you can give it a try and let me know if it is fixed or if an issue persists. |
Thank you very much! Will let you know 🙂 |
Hello! Were you able to test to see if this is working? |
I just installed the insiders version, and the issue still occurs 🤔
Ah, maybe I needed to switch the pre-release version of the Python extension? UPDATE: yep, it works fine with the pre-release 😄 |
Discussed in #23386
Originally posted by pawamoy May 8, 2024
VSCode keeps spawning a pytest process to collect tests (apparently).
It runs it in my current
.venv
:/absolute/path/to/.venv/bin/python -m pytest -p vscode_pytest --collect-only --config-file=config/pytest.ini
.The process never stops and consumes one CPU entirely.
My pytest config:
If I run the command myself:
Without the
vscode_pytest
plugin:Any idea why the process hangs and consumes an entire CPU?
Could be related to microsoft/pylance-release#4218 🤷
As mentioned in the discussion, I isolated the issue. It only happens when my pytest config file is in a subdirectory.
This works fine:
While this consumes a CPU and never finishes:
The text was updated successfully, but these errors were encountered: