如何为单个包生成覆盖率 xml 报告?
我使用nose和覆盖率来生成覆盖率报告。我现在只有一个包,ae,所以我指定只覆盖它:
nosetests -w tests/unit --with-xunit --with-coverage --cover-package=ae
以下是结果,看起来不错:
Name Stmts Exec Cover Missing
----------------------------------------------
ae 1 1 100%
ae.util 253 224 88% 39, 63-65, 284, 287, 362, 406
----------------------------------------------
TOTAL 263 234 88%
----------------------------------------------------------------------
Ran 68 tests in 5.292s
但是,当我运行 coverage xml
时,覆盖率拉入不必要的包,包括与我的代码无关的 python email 和 logging 包。
如果我运行 coverage xml ae
,我会收到此错误:
No source for code: '/home/wraith/dev/projects/trimurti/src/ae':
[Errno 21] Is a directory: '/home/wraith/dev/projects/trimurti/src/ae'
Is there a way to generated the XML for just the ae package?
I'm using nose and coverage to generate coverage reports. I only have one package right now, ae, so I specify to only cover that:
nosetests -w tests/unit --with-xunit --with-coverage --cover-package=ae
And here are the results, which look good:
Name Stmts Exec Cover Missing
----------------------------------------------
ae 1 1 100%
ae.util 253 224 88% 39, 63-65, 284, 287, 362, 406
----------------------------------------------
TOTAL 263 234 88%
----------------------------------------------------------------------
Ran 68 tests in 5.292s
However when I run coverage xml
, coverage pulls in more packages than necessary, including python email and logging packages which have nothing to do with my code.
If I run coverage xml ae
, I get this error:
No source for code: '/home/wraith/dev/projects/trimurti/src/ae':
[Errno 21] Is a directory: '/home/wraith/dev/projects/trimurti/src/ae'
Is there a way to generate the XML for just the ae package?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我遇到了类似的问题并使用
--omit
选项解决了它。这使其运行速度更快,并将coverage.xml 的大小从2MB 减少到70kB。我使用的是 Mac OS X,因此省略了 /Library/ 和 /Applications/ 文件夹:
在其他系统上,您可能会发现
--omit=/usr/
更有帮助。I had a similar problem and solved it with the
--omit
option. This made it run much faster and reduced the size of coverage.xml from 2MB to 70kB.I'm on Mac OS X, so I omitted the /Library/ and /Applications/ folders:
On other systems, you may find
--omit=/usr/
more helpful.你尝试过吗:
Did you try:
我无法找到这个问题的答案,所以我在处理后剥离不需要的包元素。此函数采用原始 XML 文件、要检查的元素名称、要检查的属性、要保留的模式(或单词列表)以及新文件的目标文件路径。
为了解决我的问题,我这样称呼它:
I wasn't able to find the answer to this, so I'm stripping the unwanted package elements out after processing. This function takes the original XML file, the element name to check, its attribute to check, the pattern (or list of words) you'd like to KEEP, and a destination filepath for the new file.
To solve my problem, I'm calling it like this: