Skip to content

Commit d5eaf3f

Browse files
committed
test: a branchless way to re-add extensions
With the `if ext` branch, we had a missing branch in our coverage results. I'm not sure how to get an extensionless file into the tests, since annotate only works on runnable Python files. So instead, switch to a branchless way to re-attach the extensions, so we don't have the distracting branch miss in the coverage results.
1 parent 57e52fd commit d5eaf3f

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

‎coverage/annotate.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ def annotate_file(self, fr: FileReporter, analysis: Analysis) -> None:
8181
# Put the original extension back, whatever it is: .py, .pyw, or
8282
# something a plugin measures.
8383
ext = os.path.splitext(rel_fname)[1]
84-
if ext:
85-
dest_file = dest_file[: -len(ext)] + ext
84+
dest_file = dest_file[: len(dest_file) - len(ext)] + ext
8685
else:
8786
dest_file = fr.filename
8887
dest_file += ",cover"

0 commit comments

Comments
 (0)