django_coverage_plugin icon indicating copy to clipboard operation
django_coverage_plugin copied to clipboard

need concrete examples of .coveragerc template configuration

Open edwardotis opened this issue 9 years ago • 7 comments

Hello,

I cannot get this plugin configured to process my template directories. There is no relevant example code either here or at the main https://coverage.readthedocs.org. https://coverage.readthedocs.org/en/coverage-4.0.3/config.html#config

Please add a sample .coveragerc based on the django standard layout for templates.

Thank you.

edwardotis avatar Feb 21 '16 07:02 edwardotis

@edwardotis can you show what you tried, and what happened?

nedbat avatar Feb 21 '16 14:02 nedbat

If you are using LiveServerTestCases - or any non-single-process test - you have to follow the coverage docs for parallel/multiprocessing and use coverage combine

PamelaM avatar Jan 16 '17 01:01 PamelaM

Necro, but still relevant, I guess.

@nedbat I just installed this today, running on django 2.0, coverage 4.5.1 and the plugin 1.6.0

My .coveragerc:

[run]
plugins =
    django_coverage_plugin

omit =
    doc/*
    tests/*
    setup/wsgi.py
    rest_framework/*

It finds no templates at all. I believe this is related to #46

But, pertaining to this particular issue, let's just say I don't know how to use the source= and include= options.

I specified source = /app/templates/* and source = /app/templates/app/*, both of which resulted in coverage: no data gathered.

velis74 avatar Sep 11 '18 06:09 velis74

Thanks for the feedback.

I'm planning to add documentation on this front. You want the source to be the source of the project/package which is being tested, not just the template sources.

Take a look at this example .coveragerc. It's being run by this command. Is that helpful at all? Is the project you're working on available for me to look at? What command are you using to run your tests? What testing tools are you using?

You may also find cookiecutter-django's config useful.

jambonrose avatar Sep 11 '18 18:09 jambonrose

Based on your suggested .coveragerc files, I found that include works while source still results in no coverage data gathered. I tried , app/ for source, both with same effect. Please note that even include does not make the templates work, it just doesn't completely fail.

To answer your questions:

  • Your first example was not helpful: there was no discernible difference by adding the [report] section to my .coveragerc.
  • The project is https://github.com/velis74/DynamicForms, but please don't take it too seriously at this stage - we haven't even decided on JavaScript linter yet. It's far from production-ready at this point.
  • the command to run tests is coverage run manage.py test. Usually I run it from PyCharm though.
  • No special testing tools: right now we're using standard django (2.0) + DRF (latest) + selenium (latest) and standard django tests. We're not testing JS yet. We just started with django-coverage-plugin to establish groundwork for the templates too. All of this on python 3.6. Regression follows too. We want functionality first.

velis74 avatar Sep 11 '18 21:09 velis74

Got a bit more info: when run on my macbook, it was failing (exception) because debugging django templates was not turned on. Still doesn't work after turning it on though. This exception wasn't raised running on Windows though.

velis74 avatar Sep 16 '18 06:09 velis74

Thanks for all the info! I will have some time to really look into this later this week, and will try to get to the bottom of the behavior you are describing.

Quick Update September 29: Have started poking around on this front and have begun putting some docs together. Will be updating ASAP.

jambonrose avatar Sep 17 '18 12:09 jambonrose