Skip to content
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

Report test coverage for Django templates #2127

Merged
merged 2 commits into from
Nov 8, 2023
Merged

Conversation

bemoody
Copy link
Collaborator

@bemoody bemoody commented Nov 7, 2023

This adds and enables the use of django-coverage-plugin (https://github.com/nedbat/django_coverage_plugin).

With this change, code coverage reports (which are included in some of the workflow logs, though they're currently hard to access and hard to use) should include information on which template files, and which parts of the file, are exercised by the test suite.

Benjamin Moody added 2 commits November 7, 2023 17:17
This is a little package that extends coverage.py, to allow measuring
and reporting test coverage for Django template files.

https://github.com/nedbat/django_coverage_plugin
django_coverage_plugin allows measuring test coverage for Django
templates.  By enabling this plugin, the coverage reports generated by
GitHub workflows should include template files (.html and others)
alongside the existing .py files.

This appears to require explicitly setting
settings.TEMPLATES[]['OPTIONS']['debug'].  I'm not sure if that has
any effect on Django itself, since according to the Django docs, this
should default to the value of settings.DEBUG.
@bemoody
Copy link
Collaborator Author

bemoody commented Nov 7, 2023

For example:

Name                                                                                        Stmts   Miss  Cover   Missing
-------------------------------------------------------------------------------------------------------------------------
console/__init__.py                                                                             0      0   100%
console/admin.py                                                                                4      0   100%
console/apps.py                                                                                 3      0   100%
console/fixtures/demo-console.json                                                              2      2     0%   1-2
console/forms.py                                                                              513    158    69%   95, 186, 203, 275, 277, 279, 317-319, 352-370, 405-407, 410-415, 418-429, 449-451, 454-459, 462-473, 504-508, 511-519, 545-547, 550-554, 557-565, 595-597, 600-604, 607-615, 668-681, 684-687, 700-703, 716-722, 725-729, 752-756, 759-781, 794-799, 827, 830, 843, 876, 908, 921-925, 933
console/migrations/__init__.py                                                                  0      0   100%
console/models.py                                                                               1      0   100%
console/services.py                                                                            32     11    66%   18-26, 32-34, 40
console/tasks.py                                                                               66     32    52%   86-87, 89, 128, 130, 138-150, 158-164, 173-179
console/templates/console/access_request.html                                                  19      2    89%   24-25
console/templates/console/add_featured.html                                                    50     36    28%   25-60
console/templates/console/application_display_table.html                                      106     10    91%   9, 13, 26, 35, 76-79, 99, 104
console/templates/console/archived_submissions.html                                            43      2    95%   37-38
console/templates/console/awaiting_authors.html                                                69     69     0%   1-83
console/templates/console/base_console.html                                                    32      0   100%
console/templates/console/code_of_conduct_detail.html                                          14      0   100%
console/templates/console/code_of_conduct_list.html                                            84      6    93%   35-36, 42-43, 77-78
...
user/widgets.py                                                                                 6      0   100%
-------------------------------------------------------------------------------------------------------------------------
TOTAL                                                                                       65000  43105    34%

@tompollard
Copy link
Member

looks good to me!

@tompollard tompollard merged commit cece757 into dev Nov 8, 2023
11 checks passed
@tompollard tompollard deleted the django-template-coverage branch November 8, 2023 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants