提交 3c2c06d0 编写于 作者: L Lukáš Doktor

test: Set "srcdir" on "__init__"

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: NLukáš Doktor <ldoktor@redhat.com>
上级 e9bec7fa
......@@ -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):
"""
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册