For a given python file that has the following lines at the top:
import traceback
import datetime
from django.contrib.contenttypes import generic
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.conf import settings
How do I write unit tests that will result in nose not showing 'missing' for those lines?
I think if it shows those lines as missing in code coverage, that means that this module was never used or imported. Those lines will show as covered in the report as long as you are successful importing those modules, and no extra tests are needed to validate the ability to import those well tested django modules. As long as you have a single test that tests something in that module, you should be fine. For example:
will result in 100% coverage when running under nose with
--with-coverageoption for this particular file. I commented outdjango.contribpackages because I'm not usingdjango-noseand do not have proper settings for this example, but it should not matter.