django_coverage_plugin: How to find templates that are never executed?
With .py files, --source
will find files that were never even executed once. What’s the equivalent for template files?
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 1
- Comments: 17 (5 by maintainers)
+1 to fix this issue and +1 for every file in TEMPLATES[‘DIRS’] can be considered a template file. (people can use omit if they put non-templates in there.)
fyi, I still cannot get this plugin configured to pick up a single template.
I can’t speak for every project, but for ours, every file in TEMPLATE_DIRS is a template.
One could add optional settings for: (a) template_extensions (defaults to .*, but for most of us it will be .html) (b) If you open a file, parse it, and there’s no template language (e.g. ‘{%’ or ‘{{’), it’s not a template
But I think treating the TEMPLATE_DIRS as containing all templates will be good enough.
@charettes : I am able to see missing templates from my test run even when they are in a
templates
directory at the root of the project. However, the results were not exactly what I expected.On top of changing the
TEMPLATES
setting, I informed.coveragerc
of the newtemplates
directory.Output for
templates
dir:The
logout.html
template is definitely not being used, so it’s correctly listed as being missing.However, running the same tests with templates in the app directory yields different results:
password_reset_done.html
is not covered.The project is setup such that Django’s Admin template is used for
password_reset_done.html
instead of the local one, so my local templates should also be at 0% coverage. I suspect that when the template is in thetemplates
directory in the root of the project, the plugin cannot differentiate between the local and admin versions (which is a bug?). Some further examination is required.The bottom line, however, is that as long as you don’t have namespace clashes between apps, you should be able to see missing templates regardless of their location. That said, please correct me if I’m not understanding the problem.
Given that #39 was merged and implements the feature, I am closing this issue.
@schinckel : When I run tests with
django_coverage_plugin
, I am seeing missing template files from app directories, and have not been able to replicate conditions where they are missing. If you’re not seeing missing templates when they’re inapp_name/templates
please open a new issue (with code, if possible!). Thank you.Several people expressed the desire to be able to match files that don’t end with
.html
or.htm
. This sounds like a reasonable feature to be, so I will be opening a new issue for that.