Skip to content

Commit

Permalink
Strip trailing slash for relative source paths
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kevin-brown authored and nedbat committed Apr 27, 2023
1 parent 2b42932 commit 4104428
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions coverage/xmlreport.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ def __init__(self, coverage: Coverage) -> None:
if os.path.exists(src):
if not self.config.relative_files:
src = files.canonical_filename(src)
else:
src = src.rstrip(r"\/")
self.source_paths.add(src)
self.packages: Dict[str, PackageData] = {}
self.xml_out: xml.dom.minidom.Document
Expand Down

0 comments on commit 4104428

Please sign in to comment.