提交 496e89d9 编写于 作者: C Cleber Rosa

Test: turn datadir into a property

The reason being that `datadir` can then be properly documented as
first class citizens so that Test class users (test writers) can rely
on it.

Other reason is that that it can be overloaded by inherited classes
such as `SimpleTest`, without the need to (re-)set other attributes
that depend on it.
Signed-off-by: NCleber Rosa <crosa@redhat.com>
上级 7c967bb0
......@@ -90,8 +90,6 @@ class Test(unittest.TestCase):
self.filename = inspect.getfile(self.__class__).rstrip('co')
self.basedir = os.path.dirname(self.filename)
self.datadir = self.filename + '.data'
self.expected_stdout_file = os.path.join(self.datadir,
'stdout.expected')
self.expected_stderr_file = os.path.join(self.datadir,
......@@ -160,6 +158,14 @@ class Test(unittest.TestCase):
self.time_elapsed = None
unittest.TestCase.__init__(self, methodName=methodName)
@property
def datadir(self):
"""
Returns the path to the directory that contains test data files
"""
filename = inspect.getfile(self.__class__).rstrip('co')
return filename + '.data'
@data_structures.LazyProperty
def workdir(self):
basename = os.path.basename(self.name)
......@@ -560,14 +566,13 @@ class SimpleTest(Test):
super(SimpleTest, self).__init__(name=name, base_logdir=base_logdir,
params=params, tag=tag, job=job)
self.path = name
basedir = os.path.dirname(self.path)
basename = os.path.basename(self.path)
datadirname = basename + '.data'
self.datadir = os.path.join(basedir, datadirname)
self.expected_stdout_file = os.path.join(self.datadir,
'stdout.expected')
self.expected_stderr_file = os.path.join(self.datadir,
'stderr.expected')
@property
def datadir(self):
"""
Returns the path to the directory that contains test data files
"""
return self.name + '.data'
def _log_detailed_cmd_info(self, result):
"""
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册