[Fixed]-How to ignore missing statemet in jenkins test coverage in django

1👍

I have found the solution of my question.
1) create .coveragerc file in your django project
2) define

JENKINS_TASKS = ('django_jenkins.tasks.run_pylint',)
COVERAGE_EXCLUDES_FOLDERS = ['packsit/migrations/*','packsit/api/v1/images.py']
COVERAGE_RCFILE = '.coveragerc' 

in your setting file.
3) .coveragerc file should contains:

[run]
branch = True

omit =
    */.local/*
    /usr/*
[report]

exclude_lines =
    pragma: no cover
    def __repr__
    if self\.debug
    raise AssertionError
    raise NotImplementedError
    if 0:
    if __name__ == .__main__.:
    return
    try:
    except:
    if
    self.*


ignore_errors = True
include = 
    packsit/api/v1/client/*
[html]
directory = coverage_html_report

then run command on terminal:

$ python manage.py jenkins --enable-coverage --coverage-format html --coverage-exclude=COVERAGE_EXCLUDES_FOLDERS 

this will exclude ‘if, return, self, try , except’ from report generated.

Leave a comment