Skip to content

Commit 4104428

Browse files
kevin-brownnedbat
authored andcommitted
Strip trailing slash for relative source paths
This fixes an issue introduced in 45cf793 where using `relative_files=True` and `src` with a trailing slash, the source inserted as `<sources>` in the XML report would also have a trailing slash. This also fixes an issue introduced in the same commit where an empty `<source>` would be inserted as well for cases where the `src` has a trailing slash.
1 parent 2b42932 commit 4104428

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

coverage/xmlreport.py

+2
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ def __init__(self, coverage: Coverage) -> None:
6969
if os.path.exists(src):
7070
if not self.config.relative_files:
7171
src = files.canonical_filename(src)
72+
else:
73+
src = src.rstrip(r"\/")
7274
self.source_paths.add(src)
7375
self.packages: Dict[str, PackageData] = {}
7476
self.xml_out: xml.dom.minidom.Document

0 commit comments

Comments
 (0)