将命令行生成的 python .coverage 文件与 PyDev 集成

发布于 2024-07-09 05:02:48 字数 279 浏览 11 评论 0原文

我的构建环境配置为在命令行编译、运行和创建覆盖文件(使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心凉 2024-07-16 05:02:48

前段时间我就需要这样的东西,当时 PyDev 仍然使用旧版本的 coverage.py ,而不是从脚本创建者页面访问的版本。

我所做的是检测 PyDev 保存其 .coverage 文件的位置。 对我来说是这样的:

 C:\Users\Admin\workspace\.metadata\.plugins\org.python.pydev.debug\.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:

 C:\Users\Admin\workspace\.metadata\.plugins\org.python.pydev.debug\.coverage

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 to coverage.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.

时光是把杀猪刀 2024-07-16 05:02:48

我对 PyDev 与coverage.py 的集成一无所知(或者它是否使用了coverage.py),但.coverage 文件非常简单。 它们是编组词典。

我尚未测试此代码,但您可以尝试将两个 .coverage 文件合并为一个:

import marshal
c1_dict = marshal.load(open(file_name_1, 'rb'))
c2_dict = marshal.load(open(file_name_2, 'rb'))
c1_dict.update(c2_dict)
marshal.dump(c1_dict, open(file_name_out, 'wb'))

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:

import marshal
c1_dict = marshal.load(open(file_name_1, 'rb'))
c2_dict = marshal.load(open(file_name_2, 'rb'))
c1_dict.update(c2_dict)
marshal.dump(c1_dict, open(file_name_out, 'wb'))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文