From a6bae5d57848f4b1a7714d9208270696ab48934d Mon Sep 17 00:00:00 2001 From: Praveen K Pandey Date: Tue, 14 May 2024 13:00:37 +0530 Subject: [PATCH] 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 Signed-off-by: Praveen K Pandey --- avocado/core/test.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/avocado/core/test.py b/avocado/core/test.py index eb79e2960e..399dccd0ea 100644 --- a/avocado/core/test.py +++ b/avocado/core/test.py @@ -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. @@ -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( @@ -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)}"