Skip to content

Commit a6bae5d

Browse files
fix a issue as file or dirortry which is part of data_dir will retrun absolute file path
As in misc test repo apply patch is failing which part of data dir as utility return relative path this patch address as it return absolute file path (file or dir) Reported-by: Geetika <[email protected]> Signed-off-by: Praveen K Pandey <[email protected]>
1 parent 17dd26c commit a6bae5d

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

avocado/core/test.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def _get_datadir(self, source):
162162

163163
return os.path.join(*paths)
164164

165-
def get_data(self, filename, source=None, must_exist=True):
165+
def get_data(self, filename, source=None, must_exist=True, abs_path=False):
166166
"""
167167
Retrieves the path to a given data file.
168168
@@ -202,7 +202,10 @@ def get_data(self, filename, source=None, must_exist=True):
202202
path,
203203
(f"assumed to be located at " f"{attempt_source} source dir"),
204204
)
205-
return path
205+
if not abs_path:
206+
return path
207+
else:
208+
return os.path.abspath(path)
206209
else:
207210
if os.path.exists(path):
208211
self.log.debug(
@@ -211,7 +214,10 @@ def get_data(self, filename, source=None, must_exist=True):
211214
path,
212215
f"found at {attempt_source} source dir",
213216
)
214-
return path
217+
if not abs_path:
218+
return path
219+
else:
220+
return os.path.abspath(path)
215221

216222
self.log.debug(
217223
log_fmt, filename, "NOT FOUND", f"data sources: {', '.join(sources)}"

0 commit comments

Comments
 (0)