diff options
Diffstat (limited to 'functest/core')
-rw-r--r-- | functest/core/feature_base.py | 10 | ||||
-rwxr-xr-x[-rw-r--r--] | functest/core/pytest_suite_runner.py | 4 | ||||
-rw-r--r-- | functest/core/testcase_base.py | 10 |
3 files changed, 15 insertions, 9 deletions
diff --git a/functest/core/feature_base.py b/functest/core/feature_base.py index 01a27f30..873e21da 100644 --- a/functest/core/feature_base.py +++ b/functest/core/feature_base.py @@ -3,6 +3,7 @@ import time import testcase_base as base import functest.utils.functest_utils as ft_utils import functest.utils.functest_logger as ft_logger +from functest.utils.constants import CONST class FeatureBase(base.TestcaseBase): @@ -11,7 +12,7 @@ class FeatureBase(base.TestcaseBase): self.project_name = project self.case_name = case self.cmd = cmd - self.repo = self.get_conf('general.directories.{}'.format(repo)) + self.repo = CONST.__getattribute__(repo) self.result_file = self.get_result_file() self.logger = ft_logger.Logger(project).getLogger() @@ -44,15 +45,10 @@ class FeatureBase(base.TestcaseBase): return exit_code def get_result_file(self): - dir = self.get_conf('general.directories.dir_results') - return "{}/{}.log".format(dir, self.project_name) + return "{}/{}.log".format(CONST.dir_results, self.project_name) def log_results(self): ft_utils.logger_test_results(self.project_name, self.case_name, self.criteria, self.details) - - @staticmethod - def get_conf(parameter): - return ft_utils.get_functest_config(parameter) diff --git a/functest/core/pytest_suite_runner.py b/functest/core/pytest_suite_runner.py index 2d5b2667..1eed92b5 100644..100755 --- a/functest/core/pytest_suite_runner.py +++ b/functest/core/pytest_suite_runner.py @@ -41,8 +41,8 @@ class PyTestSuiteRunner(base.TestcaseBase): for test, message in result.failures: self.logger.error(str(test) + " FAILED with " + message) - if (result.errors and len(result.errors) > 0) \ - or (result.failures and len(result.failures) > 0): + if ((result.errors and len(result.errors) > 0) + or (result.failures and len(result.failures) > 0)): self.logger.info("%s FAILED" % self.case_name) self.criteria = 'FAIL' exit_code = base.TestcaseBase.EX_RUN_ERROR diff --git a/functest/core/testcase_base.py b/functest/core/testcase_base.py index e869803d..838b6398 100644 --- a/functest/core/testcase_base.py +++ b/functest/core/testcase_base.py @@ -18,6 +18,7 @@ class TestcaseBase(object): EX_OK = os.EX_OK EX_RUN_ERROR = os.EX_SOFTWARE EX_PUSH_TO_DB_ERROR = os.EX_SOFTWARE - 1 + EX_TESTCASE_FAILED = os.EX_SOFTWARE - 2 logger = ft_logger.Logger(__name__).getLogger() @@ -29,6 +30,15 @@ class TestcaseBase(object): self.start_time = "" self.stop_time = "" + def check_criteria(self): + try: + assert self.criteria + if self.criteria == 'PASS': + return TestcaseBase.EX_OK + except: + self.logger.error("Please run test before checking the results") + return TestcaseBase.EX_TESTCASE_FAILED + def run(self, **kwargs): self.logger.error("Run must be implemented") return TestcaseBase.EX_RUN_ERROR |