Pytest does not show correct tests without pytest.ini
file
#24201
Labels
triage-needed
Needs assignment to the proper sub-team
pytest.ini
file
#24201
Hello, I would like to start using vscode for debuging
Python
tests. We are using thepytest
framework. I read online some guidelines on how to set up the tests UI in VSCode.I added the following in my global
settings.json
:And we are using this configuration in
pyproject.toml
file:With this I started to see some tests in the UI:
but that is just incorrect..
Then I tried adding
"python.testing.pytestArgs": ["tests"],
into the globalsettings.json
and it starts to show the test folder correctly and even picks up all the tests according to the logs, but it only shows this in the menu and no "play arrows" are "inlined" into the code near the test function definitions:Finally when I add just empty
pytest.ini
file to the root dir, and I can then remove this"python.testing.pytestArgs": ["tests"],
from the globalsettings.json
file and it starts to work properly, or rather it shows all the tests now properly with inlined "play" buttons to run them one by one from the code.However it still does not pick up the configuration from the
pyproject.toml
file so to get it working properly I need to add this to the file and now the tests work properly and I am even able to start debugger over them:My question is why does this happen, like why does not the extension pick up the
pytest
configuration from thepyproject.toml
file please? I tried multiple times fiddling with the arguments for the pytest etc. but I was not able to get it working without thepytest.ini
file.I think that my options are either to insert this file to every our repo (we have them around 200) and force this change to everyone else using other IDEs that does not pose this issue or I can add a script that is run every time I create my
poetry
venv for each project that inserts thepytest.ini
file. Either option works but is kind of cumbersome.So I started looking into the source code of the extension and found this:
vscode-python/src/client/testing/configuration/pytest/testConfigurationManager.ts
Line 53 in 9f6735e
Should not also be there the
pyproject.toml
? At every other place there ispytest.ini
there is thepyproject.toml
but not here. I wanted to verify this change but I am failing to run the recompiled extension successfully (I managed to get it installed just now, but it still refuess to start up properly).I found some similar issues but without any resolution that would apply to my case for example these:
#10722
#22643
My
vscode
version is:And the
extension
version is:v2024.14.1
Appriciate any kind of help with this. Thanks!
The text was updated successfully, but these errors were encountered: