S
S
Stanislav Gordienko2016-04-19 05:24:06
Django
Stanislav Gordienko, 2016-04-19 05:24:06

How to make coverage work with django_nose in a django project?

Hello, I've been fiddling
with coverage and django_nose in a project for two days now. One gets the feeling that they are playing a cruel joke with me together, refusing to work correctly. Tell me what am I doing wrong?
Here are the two modules I installed via pip :

coverage
django_nose

Configured django_nose launch in settings.py :
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'

NOSE_ARGS = [
    '--with-coverage',
    '--cover-html',
    '--cover-package=apps.common',
]

I have a very simple model test:
from django.test import TestCase
from django.test import Client
from django.core.urlresolvers import reverse

from .models import PuppetRole


class PuppetRoleTest(TestCase):
    def test_this_please(self):
        w = PuppetRole.objects.create(role="role_1")
        self.assertTrue(isinstance(w, PuppetRole))
        self.assertEqual(w.__str__(), "role_1")

I run it with the following command: I tried to run it with other commands as well:
$ python manage.py test
$ coverage run --branch --source=apps.common ./manage.py test
$ coverage report

As a result, a report is generated, but all lines of the model are marked in red. What have I missed?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav Gordienko, 2016-04-19
@stagor

I forgot to add that I tried to configure all this in Windows. And he was wrong. I tried to do the same on Mac and it worked for me. Windows is evil and that was probably the last time I tried to use it for development.
Yes, I was able to run coverage without django_nose and am happy with the result too.
Issue resolved. Thank you.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question