diff options
author | xudan <xudan16@huawei.com> | 2017-02-03 03:52:11 +0000 |
---|---|---|
committer | xudan <xudan16@huawei.com> | 2017-02-03 03:55:43 +0000 |
commit | 066c814c764cc3e89ccefe8bed06a9f2918ff2be (patch) | |
tree | ff0f0217eff06ddadbecb9d4b8b58f1405d8df59 | |
parent | bfb64dbd9f6b9e4ca09c017453f70b2d404e3f3f (diff) |
dovetail tool: bugfix: cannot load pre/post condition from config file
JIRA: DOVETAIL-342
Change-Id: If98905b6724c0a990d789a7ce914aeecac72d7c4
Signed-off-by: xudan <xudan16@huawei.com>
-rw-r--r-- | dovetail/testcase.py | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/dovetail/testcase.py b/dovetail/testcase.py index ed7b832e..9b6b1d7d 100644 --- a/dovetail/testcase.py +++ b/dovetail/testcase.py @@ -105,24 +105,28 @@ class Testcase(object): def pre_condition(self): try: pre_condition = self.testcase['validate']['pre_condition'] - if pre_condition == '': - pre_condition = self.pre_condition_cls(self.validate_type()) + except KeyError: + pre_condition = '' + if pre_condition: return pre_condition - except: + pre_condition = self.pre_condition_cls(self.validate_type()) + if not pre_condition: self.logger.debug('testcase:%s pre_condition is empty', self.name()) - return '' + return pre_condition def post_condition(self): try: post_condition = self.testcase['validate']['post_condition'] - if post_condition == '': - post_condition = self.post_condition_cls(self.validate_type()) + except KeyError: + post_condition = '' + if post_condition: return post_condition - except: + post_condition = self.post_condition_cls(self.validate_type()) + if not post_condition: self.logger.debug('testcae:%s post_condition is empty', self.name()) - return '' + return post_condition def run(self): runner = TestRunnerFactory.create(self) @@ -151,11 +155,17 @@ class Testcase(object): @staticmethod def pre_condition_cls(validate_type): - return dt_cfg.dovetail_config[validate_type]['pre_condition'] + try: + return dt_cfg.dovetail_config[validate_type]['pre_condition'] + except KeyError: + return None @staticmethod def post_condition_cls(validate_type): - return dt_cfg.dovetail_config[validate_type]['post_condition'] + try: + return dt_cfg.dovetail_config[validate_type]['post_condition'] + except KeyError: + return None @classmethod def update_validate_testcase(cls, testcase_name): |