coveragepy / coveragepy/django_coverage_plugin

Flaking coverage for templates

Open
#100 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
202
Forks
38
PR merge metrics
No merged PRs in 30d

Description

Hi!

What's wrong

From time to time I get random CI failures, because some .html template files are reported to be not convered. However, this is not the case. We have a full 100% coverage all the time.

Report example:

================================ tests coverage ================================
_______________ coverage: platform linux, python 3.12.10-final-0 _______________
Name                                                                      Stmts   Miss Branch BrPart  Cover   Missing
---------------------------------------------------------------------------------------------------------------------
server/apps/identity/templates/identity/emails/verification_email.html       10      9      0      0    10%   4-12
server/apps/identity/templates/identity/pages/verification_pending.html       6      5      0      0    17%   5-10
server/apps/identity/templates/password_reset/recovery_done.html              7      5      0      0    29%   3-7, 9
server/apps/identity/templates/password_reset/recovery_form.html             15     12      0      0    20%   3-12, 15-17
server/apps/identity/templates/password_reset/reset.html                     23     16      0      0    30%   3-12, 14-15, 17-18, 23-25
server/apps/identity/templates/password_reset/reset_sent.html                 9      8      0      0    11%   3-11
---------------------------------------------------------------------------------------------------------------------
TOTAL                                                                      3322     55    100      0    98%
161 files skipped due to complete coverage.
Coverage HTML written to dir htmlcov
Coverage XML written to file coverage.xml
FAIL Required test coverage of 100% not reached. Total coverage: 98.39%
============================= 150 passed in 50.03s =============================

On other runs - other .html files might be reported.

It started recently. Not sure why. The setup is rather complex, I am not able to reproduce it locally on macos, only in CI.

Repro

I have a rather complex setup basad on https://github.com/wemake-services/wemake-django-template/tree/master/%7B%7Bcookiecutter.project_name%7D%7D

Important parts:

Versions:

  • pytest: 8.3.5
  • pytest-cov: 6.1.1
  • django_coverage_plugin: 3.1.0
  • coverage: 7.8.0
  • covdefaults: 2.3.0
  • django: 5.1.8
  • python: 3.12.10

Things I've tried

Nothing really helped, except commenting out django_coverage_plugin, so .html coverage is not even calculated. It is not a good solution, because we use templates in our app.

I understand that it is rather hard to make anything without a repro, but I cannot make one just yet :(
Any help is appreciated.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked setup.cfg coverage and pytest configuration, tests/plugins/django_settings.py, and pyproject.toml dependency versions. Reproduce the intermittent CI-only failures using the listed Django template paths and compare runs with the coverage plugins enabled. Done means identifying why templates are inconsistently reported as uncovered and adding a regression test or documented fix.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, python
Domain
testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.