-
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
Pytest does not show correct tests without pytest.ini
file
#24201
Comments
Hi @lexi-k, thank you for the comprehensive bug report! I think at this point in time we do not use pytest args in the pyproject.toml, @karthiknadig can you confirm this is true and we do not adjust anywhere in the environment as it is being setup? I think the code you found with the testConfigurationManager is old code that is not being used right now which is why it may not be adjusting. @lexi-k, do you know what version of pytest you are using? What we do from the extension stand-point is just run pytest with the args provided in |
@lexi-k Can you also share the full logs from Output > Python? @eleanorjboyd I think the test adapter experiment might not be on. So, it might be running the old detection? |
Good point, @lexi-k can you check in your logs to see by searching for |
Hello, thanks for prompt responses! Let me go through it in order:
Firstly we have this in [tool.pytest.ini_options]
addopts = """
--verbose
--ruff
--mypy
--cov=cto.grafana_templates --cov-report html
"""
asyncio_mode = "auto" Running just In the When running the first configuration, by clicking on the When running the the second configuration by clicking on the Is there something more I can provide? Thanks! |
Sorry, I forget to attach the screenshots, but basically it only shows |
Hi! Sorry for the delay- is there any way you could send me a minimal repro so I can try it myself? Hard to understand all the files and arrangements without being able to try it myself and I think that would give me a better sense of what's happening |
Hello, np. Here is a minimal example. It uses |
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: