Skip to content

Conversation

@schinckel
Copy link

Resolves #94

@schinckel
Copy link
Author

Okay, this doesn't actually collect coverage on real code.

It seems to be because line_number_range(frame) bails out if the self object is an instance of django.template.base.Template, which the template used for rendering widgets is, even when using the django template backend/engine.

@nedbat do you recall why this is?

https://github.com/nedbat/django_coverage_plugin/blob/ca45852f7168d36b69e6a64f01d804b572775680/django_coverage_plugin/plugin.py#L233

@schinckel
Copy link
Author

Ah, think I figured that out - it's the nodes within a template that have the line numbers available.

The issue is that form templates use a different rendering thing, which is in a different python file, so is being omitted by file_tracer.

@schinckel
Copy link
Author

Ah, turns out it needs settings.FORM_RENDERER to be set to 'django.forms.renderers.TemplatesSetting'

@schinckel schinckel closed this Jun 21, 2024
@schinckel schinckel deleted the widget-template branch June 21, 2024 04:12
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.

Widget templates not covered (when they are clearly used).

1 participant