Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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'))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top