将命令行生成的 python .coverage 文件与 PyDev 集成
我的构建环境配置为在命令行编译、运行和创建覆盖文件(使用 Ned Batcheldercoverage.py 工具)。
我使用 Eclipse 和 PyDev 作为我的编辑器,但出于实际原因,我不可能/不方便将整个构建环境转换为 Eclipse(从而直接从 IDE 生成覆盖率数据,正如它的设计目的
)似乎使用相同的覆盖率工具(或与之非常相似的东西)来生成其覆盖率信息,所以我猜测应该有某种方法将我的外部覆盖率文件集成到 Eclipse/PyDev 中。
关于如何做到这一点有什么想法吗?
My build environment is configured to compile, run and create coverage file at the command line (using Ned Batchelder coverage.py tool).
I'm using Eclipse with PyDev as my editor, but for practical reasons, it's not possible/convenient for me to convert my whole build environment to Eclipse (and thus generate the coverage data directly from the IDE, as it's designed to do)
PyDev seems to be using the same coverage tool (or something very similar to it) to generate its coverage information, so I'm guessing there should be some way of integrating my external coverage files into Eclipse/PyDev.
Any idea on how to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
前段时间我就需要这样的东西,当时 PyDev 仍然使用旧版本的
coverage.py
,而不是从脚本创建者页面访问的版本。我所做的是检测 PyDev 保存其
.coverage
文件的位置。 对我来说是这样的:然后我从一个单独的脚本手动运行一个新版本的
coverage.py
并告诉它将其 .coverage 文件保存在 PyDev 保存它的位置。 我不记得coverage.py
是否有命令行参数,或者我是否只是用脚本复制了.coverage
文件,但在那之后,如果您只是打开代码覆盖率结果视图并单击刷新覆盖率信息!,PyDev 将很好地处理数据,就像它本身生成文件一样。I needed exactly something like this some time ago, when PyDev still used an older version of
coverage.py
than the one accessible from the script creator's page.What I did was detecting where PyDev was saving his
.coverage
file. For me it was:Then I manually ran a new version of
coverage.py
from a separate script and told it to save its .coverage file in the place where PyDev saves its. I cannot remember if there is a command-line argument tocoverage.py
or if I simply copied the.coverage
file with a script, but after that, if you simply open the Code Coverage Results View and click Refresh coverage information!, PyDev will nicely process the data as if it generated the file itself.我对 PyDev 与coverage.py 的集成一无所知(或者它是否使用了coverage.py),但.coverage 文件非常简单。 它们是编组词典。
我尚未测试此代码,但您可以尝试将两个 .coverage 文件合并为一个:
I don't know anything about PyDev's integration of coverage.py (or if it even uses coverage.py), but the .coverage files are pretty simple. They are marhsal'ed dictionaries.
I haven't tested this code, but you can try this to combine two .coverage files into one: