如何使用coverage.py从覆盖率报告中排除南方迁移
我使用 coverage.py 来检查 django 应用程序的测试覆盖率。然而,由于我使用 South 进行数据库迁移,所有这些文件都显示为 0%,并且弄乱了总体百分比。
我已经尝试在 run
和 report
(以及两者)中使用 --omit=*migrations*
但这不起作用。
我尝试了 3.4 版本和截至 2010 年 12 月 20 日 Bitbucket 的最新版本,结果相同。
有什么想法可以让coverage.py真正忽略迁移文件夹吗?
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 both) 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
解决方案是:
The solution was:
您应该能够匹配迁移目录以省略这些文件。您是否尝试过引用该论点?根据您的操作系统和 shell,它可能会过早地扩展这些星号。尝试这样:
或者,您可以将开关放入 .coveragerc 文件中:
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:
Alternately, you could put the switch into a .coveragerc file:
最新版本的 django-jenkins 具有新选项 COVERAGE_WITH_MIGRATIONS,可以排除迁移。它尚未在 PyPI 中,因此您需要使用 pip/easy_installspecyfing url git url 作为源来安装它。
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.
您是否尝试过django_coverage。我认为它可以解决此类问题。
Have you tried django_coverage. I think it handles this kind of problem.
这对我有用:
This worked for me:
尝试:
这会忽略第三方代码并修复您的 % 问题
try:
this ignores third party code and fixes your % problem