Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix a issue as file or dirortry which is part of data_dir will retrun absolute file path #5930

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 path
else:
return os.path.abspath(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 path
else:
return os.path.abspath(path)

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