Integrating command-line generated python .coverage files with PyDev

北城以北 提交于 2019-12-04 17:25:38

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.

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'))
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!