Integrating python.coverage files created on the command line with PyDev

My build environment is configured to compile, run, and create a coverage file on the command line (using the Ned Batchelder coverage.py tool).

I use Eclipse with PyDev as my editor, but for practical reasons I donโ€™t find it possible / convenient for me to convert my entire build environment to Eclipse (and thus generate coverage data directly from the IDE, since it is intended to be done)

PyDev seems to use the same coverage tool (or something very similar to it) to generate information about its coverage, so I guess there is some way to integrate my external coverage files into Eclipse / PyDev.

Any idea on how to do this?

+2
python eclipse code-coverage pydev python-coverage
source share
2 answers

I needed something like this some time ago when PyDev was still using an older version of coverage.py than the one that was available from the script creator page.

What I was doing was finding where PyDev was .coverage its .coverage file. For me it was:

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

Then I manually launched a new version of coverage.py from a separate script and told her to save his .coverage file in the place where PyDev saves it. I canโ€™t remember if there is a command line argument for coverage.py , or if I just copied the .coverage file with a script, but after that, if you just open the Code Coverage Overview view and click Update Coverage Information! PyDev will beautifully process the data as if it generated the file itself.

+3
source share

I don't know anything about integrating PyDev with cover.py (or even when it even uses cover.py), but the .coverage files are pretty simple. They are dictionaries of marhsal'ed.

I have not tested this code, but you can try this to merge 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')) 
+3
source share

All Articles