Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upDjango 1.7 model loading screws up test coverage for models #180
Comments
This comment has been minimized.
This comment has been minimized.
jchv
commented
Dec 21, 2014
I've been trying to figure this out for the past couple days. My first guess would be that the system check module is interfering with this, but unfortunately setting $ coverage run ./manage.py test
$ coverage report
$ coverage html -d cover to get things working with regular coverage. Unfortunately, this will require more manual setup, but at least it's possible to get things working this way. Right now, I don't think there's an easy fix to making coverage work inside of django-nose. :( If you want to set things up this way, you'll probably want to make a |
This comment has been minimized.
This comment has been minimized.
Yes I figured out the more manual way of doing coverage worked as before, it's just sad to see that django nose's coverage feature is so broken in 1.7 |
This comment has been minimized.
This comment has been minimized.
iyn
commented
Apr 15, 2015
Still doesn't work with Django 1.8, need to run coverage manually. Is there a way to solve this? this answer from coverage.py FAQ may be related (http://nedbatchelder.com/code/coverage/faq.html):
(emphasis mine) |
This comment has been minimized.
This comment has been minimized.
eliangcs
commented
Apr 15, 2015
One way to work around it is to modify manage.py to call coverage.start() manually: import os
import sys
if __name__ == "__main__":
# ...
from django.core.management import execute_from_command_line
is_testing = 'test' in sys.argv
if is_testing:
import coverage
cov = coverage.coverage(source=['package1', 'package2'], omit=['*/tests/*'])
cov.erase()
cov.start()
execute_from_command_line(sys.argv)
if is_testing:
cov.stop()
cov.save()
cov.report() |
This comment has been minimized.
This comment has been minimized.
iyn
commented
Apr 15, 2015
@eliangcs thanks for the workaround. |
This comment has been minimized.
This comment has been minimized.
kmmbvnr
commented
Apr 29, 2015
If there is a way to initialize and start nose coverage in That's how I fixed the coverage issue for django-jenkins - https://github.com/kmmbvnr/django-jenkins/blob/master/django_jenkins/apps.py |
jwhitlock
added
the
feature
label
May 1, 2015
jwhitlock
added
the
documentation
label
Jul 2, 2015
This comment has been minimized.
This comment has been minimized.
I'm not sure if there is a way to fix this purely in |
Jul 3, 2015
This was referenced
added a commit
to jmcarp/tock
that referenced
this issue
Jul 7, 2015
This comment has been minimized.
This comment has been minimized.
AkFede
commented
Sep 29, 2015
is there a solution in progress? |
This comment has been minimized.
This comment has been minimized.
No, I don't believe there is a solution that will work for everyone. I've found @johnwchadwick's solution to be the most reliable, and I'm using that on my own projects. |
This comment has been minimized.
This comment has been minimized.
robguttman
commented
Oct 29, 2015
Any progress on a solution for this? |
This comment has been minimized.
This comment has been minimized.
No, I don't believe there is a solution that will work for everyone. I've found @johnwchadwick's solution to be the most reliable, and I'm using that on my own projects. |
This comment has been minimized.
This comment has been minimized.
robguttman
commented
Oct 30, 2015
Deja vu! We use a number of nose plugins including for coverage (e.g., |
pushed a commit
to 18F/forecast
that referenced
this issue
Nov 21, 2015
added a commit
to yunojuno-archive/django-package-monitor
that referenced
this issue
Dec 6, 2015
heidecke
referenced this issue
Jan 9, 2016
Closed
Fix incorrect coverage reporting using nosetests #237
This comment has been minimized.
This comment has been minimized.
reinout
commented
Jun 30, 2016
•
In case someone is using buildout+djangorecipe: I just integrated @eliangcs 's solution (#180 (comment)) into djangorecipe. Works like a charm. http://reinout.vanrees.org/weblog/2016/06/30/djangorecipe-test-coverage.html |
This comment has been minimized.
This comment has been minimized.
lfritts
commented
Sep 19, 2016
@eliangcs |
diwu1989 commentedDec 21, 2014
Models are imported by the app configuration process
running ./manage.py test --with-coverage will report incorrect model coverage information because the models are all imported before the test command is executed
any way to fix this somehow?