2
votes

I'm running nose and coverage on a Django app.

I've got a structure that looks something like this:

app
..__init__.py
..tests.py
..views.py
..models.py
..urls.py
..admin.py

Now, if I run the normal manage.py test app the tests in tests.py run without an issue. However, when I hook up nose as a test suite, the tests stop running (it finds and executes 0 tests).

This is not a nose configuration issue, as I have the exact same configuration running successfully on other, similarly structured django apps.

Now, if I take the tests.py file and change it into a directory named "tests" and put all of those tests into __init__.py, the tests run using nose.

To further complicate things, when those tests DO run as an __init__ file, the coverage report is only showing coverage on admin.py, __init__.py, and models.py but it is skipping admin.py and views.py. As above, this is not a nose config issue, as I have the suite running inclusively with other, similarly structured apps and it's performing as expected.

Any clues? I'm banging my head against the wall on this one...

1
One thing I have noticed: coverage ignore some modules if you didn't imported they directly from your tests. Probably coverage ignore all those modules which wasn't imported before tests started (exclude packages - folder with __init__.py), but some of them can be imported automatically by django-nose or something like that. - simplylizz

1 Answers

-1
votes

Have you tried forcing django_nose to run certain tests by specifying an argument called --tests? Maybe of of these will work:

python manage.py test --tests=tests
python manage.py test --tests=app.tests
python manage.py test --tests=app.tests:MyUnitTestClass