Skip to content
This repository has been archived by the owner on Jun 5, 2024. It is now read-only.

Commit

Permalink
Adapt tests helper to Coverage 4.0 (ref #4175).
Browse files Browse the repository at this point in the history
  • Loading branch information
saimn committed Sep 22, 2015
1 parent 8463de7 commit 635aa8a
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,15 +303,24 @@ def _save_coverage(cov, result, rootdir, testing_path):
# long as 2to3 is needed). Therefore we only do this fix for
# Python 2.x.
if six.PY2:
d = cov.data
cov._harvest_data()
for key in d.lines.keys():
try:
# Coverage 4.0: _harvest_data has been renamed to get_data, the
# lines dict is private
cov.get_data()
except AttributeError:
# Coverage < 4.0
cov._harvest_data()
lines = cov.data.lines
else:
lines = cov.data._lines

for key in lines.keys():
new_path = os.path.relpath(
os.path.realpath(key),
os.path.realpath(testing_path))
new_path = os.path.abspath(
os.path.join(rootdir, new_path))
d.lines[new_path] = d.lines.pop(key)
lines[new_path] = lines.pop(key)

color_print('Saving coverage data in .coverage...', 'green')
cov.save()
Expand Down

0 comments on commit 635aa8a

Please sign in to comment.