I'm using Nose with Django (and django-nose), and I get a very odd coverage report:
$ python3 manage.py test lists
nosetests lists --with-coverage --cover-package=lists,superlists --verbosity=1
Creating test database for alias 'default'...
............
Name Stmts Miss Cover Missing
---------------------------------------------------------------------------
lists.py 0 0 100%
lists\admin.py 0 0 100%
lists\migrations\0001_initial.py 5 0 100%
lists\migrations\0002_item_text.py 5 0 100%
lists\migrations\0003_list.py 5 0 100%
lists\migrations\0004_item_list.py 5 0 100%
lists\migrations\0005_auto_20151117_1835.py 5 0 100%
lists\migrations.py 0 0 100%
lists\models.py 6 6 0% 1-12
lists\urls.py 3 0 100%
lists\views.py 23 0 100%
superlists.py 0 0 100%
superlists\settings.py 19 19 0% 14-113
superlists\urls.py 5 0 100%
---------------------------------------------------------------------------
TOTAL 81 25 69%
----------------------------------------------------------------------
Ran 12 tests in 0.073s
My settings are configured with:
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
NOSE_ARGS = [
'--with-coverage',
'--cover-package=lists,superlists',
]
And those obviously are read as it manages to apply the arguments and looks at my lists
and superlists
(I'm doing the TDD with Python book) apps just fine. For some reason, however, it says it didn't cover any of the settings.py
file or my lists/models.py
; very simple classes that just have some field definitions, no functions, no methods. If a 'root-level' class is in a module and is imported, all its class-attribute and method signatures (def x(...):
lines) are executed, successfully, otherwise it would crash immediately.
The settings file must be executed, otherwise Django wouldn't even run. Why is the coverage report that and the models as misses?