Skip to content

Commit

Permalink
fix a issue as file or dirortry which is part of data_dir will retrun…
Browse files Browse the repository at this point in the history
… 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]>
  • Loading branch information
PraveenPenguin committed May 17, 2024
1 parent 17dd26c commit 1847489
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions avocado/core/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def _get_datadir(self, source):

return os.path.join(*paths)

def get_data(self, filename, source=None, must_exist=True):
def get_data(self, filename, source=None, must_exist=True, abs_path=False):
"""
Retrieves the path to a given data file.
Expand Down Expand Up @@ -202,7 +202,10 @@ def get_data(self, filename, source=None, must_exist=True):
path,
(f"assumed to be located at " f"{attempt_source} source dir"),
)
return path
if not abs_path:
return os.path.abspath(path)
else:
return path
else:
if os.path.exists(path):
self.log.debug(
Expand All @@ -211,7 +214,10 @@ def get_data(self, filename, source=None, must_exist=True):
path,
f"found at {attempt_source} source dir",
)
return path
if not abs_path:
return os.path.abspath(path)
else:
return path

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

0 comments on commit 1847489

Please sign in to comment.