Skip to content

Commit 835f917

Browse files
blueyeddbarnett
authored andcommitted
Fix GetCoveragePyLines for coverage.py 5 (#35)
1 parent 6a01d86 commit 835f917

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

python/vim_coverage.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,15 @@ def GetCoveragePyLines(path, source_file):
3333
cov.load()
3434
finally:
3535
os.chdir(prev_cwd)
36+
try:
37+
data = cov.get_data()
38+
except AttributeError:
39+
# Coverage.py before 5.
40+
data = cov.data
3641
try:
3742
# Coverage.py 4.0 and higher.
38-
covered_lines = cov.data.lines(source_file)
43+
covered_lines = data.lines(source_file)
3944
except TypeError:
40-
covered_lines = cov.data.line_data()[source_file]
45+
covered_lines = data.line_data()[source_file]
4146
uncovered_lines = cov.analysis(source_file)[2]
4247
return (covered_lines or [], uncovered_lines)

0 commit comments

Comments
 (0)