Skip to content

Commit 331086f

Browse files
committed
[xmlreport] when a filepath is in multiple source dirs, choose the highest one
fixes #578
1 parent 2afc907 commit 331086f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

coverage/xmlreport.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def xml_file(self, fr, analysis, has_arcs):
148148
# Create the 'lines' and 'package' XML elements, which
149149
# are populated later. Note that a package == a directory.
150150
filename = fr.filename.replace("\\", "/")
151-
for source_path in self.source_paths:
151+
for source_path in sorted(self.source_paths, key=len):
152152
source_path = files.canonical_filename(source_path)
153153
if filename.startswith(source_path.replace("\\", "/") + "/"):
154154
rel_name = filename[len(source_path)+1:]

0 commit comments

Comments
 (0)