开发者

How can I exclude South migrations from coverage reports using coverage.py

开发者 https://www.devze.com 2023-01-31 10:35 出处:网络
I use coverage.pyto check the test coverage of my django application. However since I use South for my database migrations, all those files show up with 0% and mess up the overall percentage.

I use coverage.py to check the test coverage of my django application. However since I use South for my database migrations, all those files show up with 0% and mess up the overall percentage.

I already tried using --omit=*migrations* in both run and report (and bot开发者_开发问答h) but that didn't work.

I tried versions 3.4 and latest revision from Bitbucket as of Dec 20th 2010 with the same result.

Any ideas how I can get coverage.py to actually ignore the migrations folders?


The solution was:

[run]
omit = ../*migrations*


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*


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.


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


This worked for me:

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


try:

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

this ignores third party code and fixes your % problem

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号