[Django]-How can I exclude South migrations from coverage reports using coverage.py

29๐Ÿ‘

The solution was:

[run]
omit = ../*migrations*
๐Ÿ‘คJonas Obrist

27๐Ÿ‘

You should be able to match against the migrations directory to omit those files. Have you tried quoting the argument? Depending on your OS and shell, it may be expanding those asterisks prematurely. Try it like this:

--omit='*migrations*'

Alternately, you could put the switch into a .coveragerc file:

[run]
omit = *migrations*
๐Ÿ‘คNed Batchelder

2๐Ÿ‘

Latest version of django-jenkins has new option COVERAGE_WITH_MIGRATIONS that would exclude migrations. Itโ€™s not in PyPI yet so you need to install it with pip/easy_install specyfing url git url as source.

๐Ÿ‘คDimmuR

1๐Ÿ‘

Have you tried django_coverage. I think it handles this kind of problem.

๐Ÿ‘คluc

0๐Ÿ‘

This worked for me:

coverage run --source='.' --omit='*/migrations/*.py' manage.py test

-3๐Ÿ‘

try:

coverage run --source=. manage.py test app_name

this ignores third party code and fixes your % problem

๐Ÿ‘คuser1422535

Leave a comment