diff --git a/coverage/xmlreport.py b/coverage/xmlreport.py index 8c8409dc5..e14a19ea5 100644 --- a/coverage/xmlreport.py +++ b/coverage/xmlreport.py @@ -148,7 +148,7 @@ def xml_file(self, fr, analysis, has_arcs): # Create the 'lines' and 'package' XML elements, which # are populated later. Note that a package == a directory. filename = fr.filename.replace("\\", "/") - for source_path in self.source_paths: + for source_path in sorted(self.source_paths, key=len): source_path = files.canonical_filename(source_path) if filename.startswith(source_path.replace("\\", "/") + "/"): rel_name = filename[len(source_path)+1:]