You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature Request - Function and class coverage in "coverage report" #1859
The problem is that it requires to open two HTML files ("class_index.html" and "function_index.html") in a browser at each run of coverage html, which doesn't suit terminal-based CI/CD pipelines and workflows.
Feature Request
I kindly request, if possible, to have the same content of "class_index.html" and "function_index.html" as output of the coverage report command? - i.e:
changed the title [-]Function and class coverage in "coverage report"[/-][+]Feature Request - Function and class coverage in "coverage report"[/+]on Sep 23, 2024
I have an old branch that adds something like this: master...devdanzin:coveragepy:report_on_regions. There's a sample of what it outputs (or used to, not sure it's working after recent refactorings) in issue #1793 (where it was decided to not add this information to the textual report then).
I won't be able to work on it for a couple of weeks, but would be glad to polish and update it if it's deemed desirable. Feel free to adapt it and submit as a PR before I'm back if you want to (and @nedbat agrees, of course).
I won't be able to work on it for a couple of weeks, but would be glad to polish and update it if it's deemed desirable. Feel free to adapt it and submit as a PR before I'm back if you want to
I'm a Python developer myself, but I'm not familiar with the coverage.py codebase and it would take me some days in sequence to understand its structure (which I lack of at the moment) before being able to contribute.
I bet it will be way faster to wait for somebody else to add this feature! I'll keep using my workaround until then!
I bet it will be way faster to wait for somebody else to add this feature!
Good news: I've merged master into my branch and it works as-is. If you can, please install coverage from that branch and check whether it does everything you want, the way you'd like it to. I'm open to changing the output format and other features to better suit your needs.
For this to land as an official feature, besides being approved by the maintainer, it would still need some tests and some cleanup (mostly to mirror the cleaner code organization in jsonreport.py). I should be able to work on this during the weekend.
How can I install your updated version of coverage.py? Does pip install <github link> work?
I tested and pip install -U git+https://github.com/devdanzin/coveragepy.git@report_on_regions seems to work for that.
I would expect your feature to output a formatted table like the one that I get from my latest workaround:
Currently output for coverage report --functions --classes (it's possible to pass either, both or none) is formatted like below. It should be simple to format like what you have, except that it's not currently possible to get the excluded lines data from the text report (see #814).
Name Stmts Miss Cover
---------------------------------------------------------------------
coverage/version.py 16 0 100%
coverage/version.py: function _make_url 1 0 100%
coverage/version.py: function _make_version 8 0 100%
setup.py 68 25 63%
setup.py: class BuildFailed 2 2 0%
setup.py: class ve_build_ext 12 12 0%
setup.py: function BuildFailed.__init__ 2 2 0%
setup.py: function main 8 5 38%
setup.py: function ve_build_ext.build_extension 8 8 0%
setup.py: function ve_build_ext.run 4 4 0%
---------------------------------------------------------------------
TOTAL 84 25 70%
Activity
[-]Function and class coverage in "coverage report"[/-][+]Feature Request - Function and class coverage in "coverage report"[/+]devdanzin commentedon Sep 25, 2024
I have an old branch that adds something like this: master...devdanzin:coveragepy:report_on_regions. There's a sample of what it outputs (or used to, not sure it's working after recent refactorings) in issue #1793 (where it was decided to not add this information to the textual report then).
I won't be able to work on it for a couple of weeks, but would be glad to polish and update it if it's deemed desirable. Feel free to adapt it and submit as a PR before I'm back if you want to (and @nedbat agrees, of course).
numbworks commentedon Sep 25, 2024
@devdanzin
Thank you for your answer!
I'm a Python developer myself, but I'm not familiar with the
coverage.pycodebase and it would take me some days in sequence to understand its structure (which I lack of at the moment) before being able to contribute.I bet it will be way faster to wait for somebody else to add this feature! I'll keep using my workaround until then!
devdanzin commentedon Sep 30, 2024
Good news: I've merged master into my branch and it works as-is. If you can, please install coverage from that branch and check whether it does everything you want, the way you'd like it to. I'm open to changing the output format and other features to better suit your needs.
For this to land as an official feature, besides being approved by the maintainer, it would still need some tests and some cleanup (mostly to mirror the cleaner code organization in jsonreport.py). I should be able to work on this during the weekend.
numbworks commentedon Sep 30, 2024
@devdanzin
Thank you for your time and work!
I'll try to find two hours to setup a temp devcontainer and try it out.
How can I install your updated version of coverage.py? Does
pip install <github link>work?In the meanwhile, I do provide to you a first quick answer!
I would expect your feature to output a formatted table like the one that I get from my latest workaround:
The screenshot comes from the following project: nwreadinglist.
My latest workaround works by installing Pandoc in the dev environment (devcontainer):
and asking it to format the table I extract from
htmlcov:devdanzin commentedon Sep 30, 2024
I tested and
pip install -U git+https://github.com/devdanzin/coveragepy.git@report_on_regionsseems to work for that.Currently output for
coverage report --functions --classes(it's possible to pass either, both or none) is formatted like below. It should be simple to format like what you have, except that it's not currently possible to get the excluded lines data from the text report (see #814).numbworks commentedon Oct 6, 2024
@devdanzin
Finally Sunday! I apologize for the slightly delayed answer!
As far as there is the class name and the coverage % in a formatted table, it's good enough to quickly add tests where required!
Thank you for your work so far! I'll update this thread once I try it out!
numbworks commentedon Dec 9, 2024
@devdanzin
Sorry for the delay! Seems to work okay! I would definitely create a pull request for it!