Skip to content

Commit

Permalink
Fix GetCoveragePyLines for coverage.py 5 (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
blueyed authored and dbarnett committed Apr 3, 2019
1 parent 6a01d86 commit 835f917
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions python/vim_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,15 @@ def GetCoveragePyLines(path, source_file):
cov.load()
finally:
os.chdir(prev_cwd)
try:
data = cov.get_data()
except AttributeError:
# Coverage.py before 5.
data = cov.data
try:
# Coverage.py 4.0 and higher.
covered_lines = cov.data.lines(source_file)
covered_lines = data.lines(source_file)
except TypeError:
covered_lines = cov.data.line_data()[source_file]
covered_lines = data.line_data()[source_file]
uncovered_lines = cov.analysis(source_file)[2]
return (covered_lines or [], uncovered_lines)

0 comments on commit 835f917

Please sign in to comment.