diff --git a/coverage/lcovreport.py b/coverage/lcovreport.py index 4dc73c297..30be72e9f 100644 --- a/coverage/lcovreport.py +++ b/coverage/lcovreport.py @@ -42,8 +42,11 @@ def get_lcov(self, fr, analysis, outfile=None): outfile.write("TN:\n") outfile.write(f"SF:{fr.relative_filename()}\n") source_lines = fr.source().splitlines() - + sorted_excluded = sorted(analysis.excluded) for covered in sorted(analysis.executed): + if executed in sorted_excluded: + # Do not report excluded as executed + continue # Note: Coverage.py currently only supports checking *if* a line # has been executed, not how many times, so we set this to 1 for # nice output even if it's technically incorrect.