Skip to content

Commit

Permalink
wip: #1280
Browse files Browse the repository at this point in the history
  • Loading branch information
nedbat committed Oct 30, 2022
1 parent f93c620 commit 915d4c1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion coverage/python.py
Expand Up @@ -151,7 +151,14 @@ def __init__(self, morf, coverage=None):

filename = source_for_morf(morf)

super().__init__(canonical_filename(filename))
fname = filename
canonicalize = True
if self.coverage is not None:
if self.coverage.config.relative_files:
canonicalize = False
if canonicalize:
fname = canonical_filename(filename)
super().__init__(fname)

if hasattr(morf, '__name__'):
name = morf.__name__.replace(".", os.sep)
Expand Down
3 changes: 2 additions & 1 deletion coverage/xmlreport.py
Expand Up @@ -149,7 +149,8 @@ def xml_file(self, fr, analysis, has_arcs):
# are populated later. Note that a package == a directory.
filename = fr.filename.replace("\\", "/")
for source_path in self.source_paths:
source_path = files.canonical_filename(source_path)
if not self.config.relative_files:
source_path = files.canonical_filename(source_path)
if filename.startswith(source_path.replace("\\", "/") + "/"):
rel_name = filename[len(source_path)+1:]
break
Expand Down

0 comments on commit 915d4c1

Please sign in to comment.