-
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
No line number colours after running tests with pytest #24176
Comments
Yes
|
ok it seems like on windows right now it is not working- still investigating this |
Sorry if this sounds like I’m hijacking the conversation, but I beg to differ. The latest VS release mentions test coverage for Python: https://code.visualstudio.com/updates/v1_94#_python I assumed this was for the Production release, not just the Insider build. However, I don’t see it working. Also, this page: https://code.visualstudio.com/docs/python/testing#_run-tests-with-coverage is missing an image. Clearly, something is broken or, at the very least, poorly documented. However, when I run it, I don't see the report coverage you mentioned @eleanorjboyd Needless to say that The relevant part: [tool.pytest.ini_options]
addopts = "tests --cov=process_dcm/ --cov-report=term-missing:skip-covered --cov-report=xml --dist=loadgroup -n 8 --durations=5"
[tool.coverage.report]
omit = ["__main__.py"]
exclude_lines = ["no cov", "if __name__ == .__main__.:", "if TYPE_CHECKING:"] |
Hi! This is for the production release- our docs do not mention it (we are adding it as it was an oversight) but you need to be on the rewrite to use it- maybe that is the problem? To switch to the rewrite if you aren't in the experiment, you can do so adding this setting to your users settings.json "python.experiments.optInto": ["pythonTestAdapter"]. Then you can confirm its enabled by finding Experiment 'pythonTestAdapter' is active in your python logs. If you are unable to see the log for the experiment change your log level to trace and it should show up. To set to trace use theDeveloper: set log level command in the command palette. Thanks |
Thanks @eleanorjboyd so I got it to work. Using vscode 1.94.2. However it still have problems, serious problems. The coverage report to start with, is wrong: On terminal is the result when I run my pytest. Second, this issue is back #23223 please, reopen it. |
Ok, by fine-tuning But then, the debugger stop working properly by not stopping at the breakpoints. I think we need a different property for coverage, say Perhaps I could create other Run and Debug profiles but I don't know how to do this, if this is really possible. So, the way I work, I need vscode to help me debug so I have to keep "python.testing.pytestArgs": [
"tests",
"-v",
"-c",
"tests/pytest.ini" # empty dummy file
], And when I want coverage etc, I use command line [tool.pytest.ini_options]
addopts = "tests --cov=process_dcm/ --cov-report=term-missing:skip-covered --cov-report=xml --dist=loadgroup -n 8 --durations=5"
[tool.coverage.report]
omit = ["__main__.py"]
exclude_lines = ["no cov", "if __name__ == .__main__.:", "if TYPE_CHECKING:"] Plus Coverage Gutters extension to visualise the coverage. I'm going back to my usual workflow. This vscode coverage is indeed very experimental. |
Hi! Sorry about the delay and glad you got it working- yes that makes sense that you need to coverage arg, wondering if you could try with a secondly yes we really want to have ways to specify args for different types of runs. We are working on it but it is a bit larger so is taking more time- you can follow along here: #23907. Could be useful to have a setting for coverage args in the meantime... let me give that some thought. |
Testing #24156
VS Code: latest Insiders on Windows
Virtual environment: conda with Python 3.11.9
I don't see red or green on the line numbers indicating which branches were covered when running test_unit_and_pytest_combo.py. I am using a Python profile, but the same issue happens on my default profile.
The text was updated successfully, but these errors were encountered: