From b7fc90dca7bed9f5dffe615a4fdba1dac9ea57d5 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Thu, 28 Oct 2021 06:17:58 -0400 Subject: test: add a annotate test, and simplify the logic --- coverage/annotate.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'coverage') diff --git a/coverage/annotate.py b/coverage/annotate.py index 9ca1b80a..07ff644d 100644 --- a/coverage/annotate.py +++ b/coverage/annotate.py @@ -74,8 +74,7 @@ class AnnotateReporter: dest_file = fr.filename + ",cover" with open(dest_file, 'w', encoding='utf-8') as dest: - i = 0 - j = 0 + i = j = 0 covered = True source = fr.source() for lineno, line in enumerate(source.splitlines(True), start=1): @@ -89,9 +88,7 @@ class AnnotateReporter: dest.write(' ') elif self.else_re.match(line): # Special logic for lines containing only 'else:'. - if i >= len(statements) and j >= len(missing): - dest.write('! ') - elif i >= len(statements) or j >= len(missing): + if j >= len(missing): dest.write('> ') elif statements[i] == missing[j]: dest.write('! ') -- cgit v1.2.1