3

I'm using django-nose in order to measuring coverage of my test suite.
I followed this doc to do this.

With the standard configuration works well, and i succeed in cover all my application.

I would exclude views directory from the coverage without install new packages, so I tried to use --ignore-files parameter in this way:

NOSE_ARGS = [
    '--with-coverage',
    '--cover-package=apps.my_app',
    '--ignore-files=^views\\.'
]

My project structure is

+- root
|-- src
|--- main
|---- apps
|----- my_app
|------ views
|--- test
|---- main
|----- apps
|------ my_app
|------- views

And I run the test suite from project root with the following command:

python src\main\manage.py test --noinput main

Unfortunately it doesn't work correctly, I mean that django-nose seems ignore this option and views directory is included in the coverage.

What i'm missing?

Giordano
  • 5,422
  • 3
  • 33
  • 49

1 Answers1

4

You can configure coverage.py to exclude files from analysis, and to exclude files from coverage's report. I've done this successfully using django-nose.

Add a .coveragerc file, in the same directory coverage.py is being run (where you run your tests from), with something like the following ->

[run]
omit = 
    my/folder/*


[report]
omit = 
    my/folder/*
knopch1425
  • 709
  • 6
  • 19