Closed RensDimmendaal closed 3 years ago
@RensDimmendaal Thanks for submitting an issue! I wasn't able to reproduce this with the latest version of vscode and the example project 🤔
Usually this is an issue with the generated html file, can you confirm that you have the latest coverage py package?
Closing due to staleness, happy to reopen!
I'm seeing this issue as well and haven't been able to correct it. Gutters work fine, the report is the only issue.
Is there anything I can do like turning up logging, etc.? Any other troubleshooting?
@cdonnellytx There is a couple things you can try. 1) Try out the example project and see if you can preview that html? (screenshot 1) https://github.com/ryanluker/vscode-coverage-gutters/tree/master/example/node
2) Can you check if there is any logging errors around the webview in the gutters log? (screenshot 2)
3) We have some security work being completed by @Kaytbode that might help with your issue if it is a security bit that is preventing the preview from loading 🤔 . https://github.com/ryanluker/vscode-coverage-gutters/issues/237
The preview works for me in the Node sample project, but not the Python one (at least initially).
A couple of things I found out by hacking some additional logging into the extension:
${workspaceRoot}/**/coverage/**/index.html
. If your test generator doesn't output HTML you won't have a file to view.pytest-cov
, it installs the coverage
package at ${venv}/Lib/site-packages/coverage
. The package includes a template file at ${venv}/Lib/site-packages/coverage/htmlfiles/index.html
. This matches the wildcard above, and is what is showing up in the webview. %LOCALAPPDATA%\programs\python\python39\lib\site-packages\coverage\htmlfiles\index.html
).Fortunately it looks like I can get pytest to generate both HTML and XML with the following in pytest.ini
:
[pytest]
# ...
addopts =
--cov=python/foobar
--cov-report xml
--cov-report html:coverage/xyz
The HTML report defaults to ${workspaceRoot}/htmlcov/
. By setting it above, I finally get a prompt to choose between the venv and it:
Which lets me select the correct report:
Ideally the search would exclude the venv directory (if there is one) under the workspace. (Or maybe I'm not supposed to put it there -- I'm fairly new to Python and so I don't know if I should be creating the venv outside the workspace tree.) This at least explains everything, though.
Found the coverage-gutters.ignoredPathGlobs
setting and was able to get rid of it searching my venv.
Looks like it excludes venv
but not .venv
by default. Python venv docs use that as a "common" name for the directory; you might want to add it to the default ignored globs...
@cdonnellytx Good find, I will add that to the defaults! You can find that addition here https://github.com/ryanluker/vscode-coverage-gutters/commit/f71d17c62e1095334d6366d8b3b82aa723f8e8b1 .
Regarding the virtual env, and where it should be located, I usually put mine in the root (C:\ or ~/ depending on the OS). Having it in the project isn't wrong either though 🤔 .
Bug: When I open the "Preview Coverage Report" I don't see the actual report but I get this template file. The gutter coverage works great though 👍
To Reproduce
Expected behaviour I expect to see the actual coverage report
Screenshots
Desktop (please complete the following information):