From 3c2c06d05f81731cd48ab9b483d2f749a98935ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= Date: Wed, 21 Mar 2018 14:36:47 +0100 Subject: [PATCH] test: Set "srcdir" on "__init__" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `srcdir` is always executed during `_setup_environment_variables`, initializing it lazily only consumes more mem and power. As a benefit having it initialized we can directly access `self.__srcdir` internally and remove the hack to not-log-warning-on-internal-access. Signed-off-by: Lukáš Doktor --- avocado/core/test.py | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/avocado/core/test.py b/avocado/core/test.py index 6e0bfcc9..03ee731d 100644 --- a/avocado/core/test.py +++ b/avocado/core/test.py @@ -396,9 +396,8 @@ class Test(unittest.TestCase, TestData): self.__workdir = os.path.join(data_dir.get_tmp_dir(), self.name.str_filesystem) - self.__srcdir_internal_access = False self.__srcdir_warning_logged = False - self.__srcdir = None + self.__srcdir = utils_path.init_dir(self.__workdir, 'src') self.log.debug("Test metadata:") if self.filename: @@ -540,14 +539,12 @@ class Test(unittest.TestCase, TestData): This property is deprecated and will be removed in the future. The :meth:`workdir` function should be used instead. """ - if not (self.__srcdir_internal_access or self.__srcdir_warning_logged): + if not self.__srcdir_warning_logged: LOG_JOB.warn("DEPRECATION NOTICE: the test's \"srcdir\" property " "is deprecated and is planned to be removed no later " "than May 11 2018. Please use the \"workdir\" " "property instead.") self.__srcdir_warning_logged = True - if self.__srcdir is None: - self.__srcdir = utils_path.init_dir(self.workdir, 'src') return self.__srcdir @property @@ -971,14 +968,7 @@ class Test(unittest.TestCase, TestData): os.environ['AVOCADO_TEST_OUTPUTDIR'] = self.outputdir if self.__sysinfo_enabled: os.environ['AVOCADO_TEST_SYSINFODIR'] = self.__sysinfodir - # srcdir is deprecated and will cause a test warning when - # accessed. It seems unfair to return a warning for all - # tests because Avocado itself will access that property. - # this is a hack to be removed when srcdir is also removed - # for good. - self.__srcdir_internal_access = True - os.environ['AVOCADO_TEST_SRCDIR'] = self.srcdir - self.__srcdir_internal_access = False + os.environ['AVOCADO_TEST_SRCDIR'] = self.__srcdir def run_avocado(self): """ -- GitLab