From b90fc8907f0c4ba716d6332159f881f880965277 Mon Sep 17 00:00:00 2001 From: Linghui Zeng Date: Mon, 14 Nov 2016 10:29:21 +0800 Subject: dovetail tool: replace the hard-coded "Tescase" and modify some classmethod JIRA: DOVETAIL-45 1. In the testcase.py file, we replace the hard-coded "Tesecase" with "cls" or "self" based on the specific contexts. 2. For all the four committed files, we modify some classmethod into staticmethod because each method is basically just a function, called syntactically like a method, but without access to the object and its' internals (attributes and other methods). Change-Id: Ieb452f476a2d33ae9aca4c904ae7d2c92b68689e Signed-off-by: Linghui Zeng --- dovetail/testcase.py | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'dovetail/testcase.py') diff --git a/dovetail/testcase.py b/dovetail/testcase.py index d505420a..b1c3b621 100644 --- a/dovetail/testcase.py +++ b/dovetail/testcase.py @@ -27,8 +27,8 @@ class Testcase: self.testcase['passed'] = False self.cmds = [] self.sub_testcase_status = {} - Testcase.update_script_testcase(self.script_type(), - self.script_testcase()) + self.update_script_testcase(self.script_type(), + self.script_testcase()) def prepare_cmd(self): for cmd in dovetail_config[self.script_type()]['testcase']['cmds']: @@ -65,14 +65,13 @@ class Testcase: def exceed_max_retry_times(self): # logger.debug('retry times:%d' % self.testcase['retry']) - return Testcase._exceed_max_retry_times(self.script_type(), - self.script_testcase()) + return self._exceed_max_retry_times(self.script_type(), + self.script_testcase()) def increase_retry(self): # self.testcase['retry'] = self.testcase['retry'] + 1 # return self.testcase['retry'] - return Testcase._increase_retry(self.script_type(), - self.script_testcase()) + return self._increase_retry(self.script_type(), self.script_testcase()) def passed(self, passed=None): if passed is not None: @@ -80,14 +79,14 @@ class Testcase: return self.testcase['passed'] def script_result_acquired(self, acquired=None): - return Testcase._result_acquired(self.script_type(), - self.script_testcase(), acquired) + return self._result_acquired(self.script_type(), + self.script_testcase(), acquired) def pre_condition(self): - return Testcase.pre_condition_cls(self.script_type()) + return self.pre_condition_cls(self.script_type()) def post_condition(self): - return Testcase.post_condition_cls(self.script_type()) + return self.post_condition_cls(self.script_type()) # testcase in upstream testing project script_testcase_list = {'functest': {}, 'yardstick': {}} @@ -107,12 +106,12 @@ class Testcase: cls.scrpit_testcase_list[script_type]['cleaned'] = cleaned return cls.script_testcase_list[script_type]['cleaned'] - @classmethod - def pre_condition_cls(cls, script_type): + @staticmethod + def pre_condition_cls(script_type): return dovetail_config[script_type]['pre_condition'] - @classmethod - def post_condition_cls(cls, script_type): + @staticmethod + def post_condition_cls(script_type): return dovetail_config[script_type]['post_condition'] @classmethod @@ -147,7 +146,7 @@ class Testcase: with open(os.path.join(root, testcase_file)) as f: testcase_yaml = yaml.safe_load(f) cls.testcase_list[testcase_yaml.keys()[0]] = \ - Testcase(testcase_yaml) + cls(testcase_yaml) logger.debug(cls.testcase_list) @classmethod -- cgit 1.2.3-korg