Mike
Mike

Reputation: 553

Coverage and nose shows files from django and not just my tests

I'm using django-nose to make tests and coverage with it. But instead of getting just my test files in console output i get lines like:

django/core/cache/backends/db.py                                               139    117    16%
django/core/cache/backends/locmem.py                                           109     82    25%
django/core/management/commands/createcachetable.py                             68     45    34%
django/core/management/commands/migrate.py                                     171     91    47%
django/core/serializers/xml_serializer.py                                      220    172    22%
django/db/migrations/autodetector.py                                           573    522     9%
django/db/migrations/executor.py                                               204    127    38%
django/db/migrations/graph.py                                                  241    116    52%
django/db/migrations/loader.py                                                 170     66    61%
django/db/migrations/optimizer.py                                               26     22    15%
django/db/migrations/questioner.py                                             129     97    25%
django/db/migrations/recorder.py                                                42      6    86%
django/db/migrations/serializer.py                                             278    199    28%
django/db/migrations/topological_sort.py                                        15     13    13%
django/db/migrations/utils.py                                                   11      4    64%
django/db/migrations/writer.py                                                 183    145    21%
django/db/models/sql/compiler.py                                               675    364    46%
django/utils/synch.py                                                           56     39    30%
django/utils/xmlutils.py                                                        16      9    44%

I run test with ./manage.py test mysite from most outer django folder. My settings are:

TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
NOSE_ARGS = ['--with-spec','--with-coverage', '--spec-color', "--exe"]

How can i show coverage of just my tests?

Upvotes: 0

Views: 665

Answers (1)

Swapnil
Swapnil

Reputation: 2603

Use NOSE_ARGS in your settings to determine all the apps that you want to test:

NOSE_ARGS = [
         '--with-coverage',
         '--cover-package=app1, app2'
         ]

where app1 and app2 are the name of your app

Note: If you have a file structure where the apps are inside a main python module then app1 should be replaced with yourproject.app1

Upvotes: 1

Related Questions