Skip to content

Commit 915d4c1

Browse files
committed
wip: #1280
1 parent f93c620 commit 915d4c1

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

coverage/python.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,14 @@ def __init__(self, morf, coverage=None):
151151

152152
filename = source_for_morf(morf)
153153

154-
super().__init__(canonical_filename(filename))
154+
fname = filename
155+
canonicalize = True
156+
if self.coverage is not None:
157+
if self.coverage.config.relative_files:
158+
canonicalize = False
159+
if canonicalize:
160+
fname = canonical_filename(filename)
161+
super().__init__(fname)
155162

156163
if hasattr(morf, '__name__'):
157164
name = morf.__name__.replace(".", os.sep)

coverage/xmlreport.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ def xml_file(self, fr, analysis, has_arcs):
149149
# are populated later. Note that a package == a directory.
150150
filename = fr.filename.replace("\\", "/")
151151
for source_path in self.source_paths:
152-
source_path = files.canonical_filename(source_path)
152+
if not self.config.relative_files:
153+
source_path = files.canonical_filename(source_path)
153154
if filename.startswith(source_path.replace("\\", "/") + "/"):
154155
rel_name = filename[len(source_path)+1:]
155156
break

0 commit comments

Comments
 (0)