aboutsummaryrefslogtreecommitdiffstats
path: root/xtesting/core/feature.py
diff options
context:
space:
mode:
authorPanagiotis Karalis <pkaralis@intracom-telecom.com>2018-05-25 12:27:12 +0300
committerCédric Ollivier <cedric.ollivier@orange.com>2018-05-29 09:17:36 +0200
commit0249623ab94035ca0ea363d9a86847c2e7a5ee93 (patch)
treedf7ccec4c512893b84c931b9f6b1c653e644d725 /xtesting/core/feature.py
parent9c04ef0bc676591c762153f5c8446e83d860ea76 (diff)
Remove Feature logger0.42
This class atttribute is removed as it's quite useless (it forces one module per project). All messages are now printed to xtesting.log whatever the namespace and all warnings are printed in console. Co-Authored-By: Cédric Ollivier <cedric.ollivier@orange.com> Change-Id: I6860eaf427093ea21b3bd78650bec7939e947b2d Signed-off-by: Panagiotis Karalis <pkaralis@intracom-telecom.com> Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
Diffstat (limited to 'xtesting/core/feature.py')
-rw-r--r--xtesting/core/feature.py36
1 files changed, 7 insertions, 29 deletions
diff --git a/xtesting/core/feature.py b/xtesting/core/feature.py
index ed053e09..932e0230 100644
--- a/xtesting/core/feature.py
+++ b/xtesting/core/feature.py
@@ -27,34 +27,6 @@ class Feature(testcase.TestCase):
"""Base model for single feature."""
__logger = logging.getLogger(__name__)
- dir_results = "/var/lib/xtesting/results"
-
- def __init__(self, **kwargs):
- super(Feature, self).__init__(**kwargs)
- self.result_file = "{}/{}.log".format(self.dir_results, self.case_name)
- try:
- module = kwargs['run']['module']
- self.logger = logging.getLogger(module)
- except KeyError:
- self.__logger.warning(
- "Cannot get module name %s. Using %s as fallback",
- kwargs, self.case_name)
- self.logger = logging.getLogger(self.case_name)
- Feature.configure_logger(self.logger, self.result_file)
-
- @staticmethod
- def configure_logger(logger, result_file):
- """Configure the logger to print in result_file."""
- handler = logging.StreamHandler()
- handler.setLevel(logging.WARN)
- logger.addHandler(handler)
- handler = logging.FileHandler(result_file)
- handler.setLevel(logging.DEBUG)
- logger.addHandler(handler)
- formatter = logging.Formatter(
- '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
- handler.setFormatter(formatter)
- logger.addHandler(handler)
def execute(self, **kwargs):
"""Execute the Python method.
@@ -104,7 +76,6 @@ class Feature(testcase.TestCase):
self.result = 100
except Exception: # pylint: disable=broad-except
self.__logger.exception("%s FAILED", self.project_name)
- self.__logger.info("Test result is stored in '%s'", self.result_file)
self.stop_time = time.time()
return exit_code
@@ -114,6 +85,11 @@ class BashFeature(Feature):
__logger = logging.getLogger(__name__)
+ def __init__(self, **kwargs):
+ super(BashFeature, self).__init__(**kwargs)
+ dir_results = "/var/lib/xtesting/results"
+ self.result_file = "{}/{}.log".format(dir_results, self.case_name)
+
def execute(self, **kwargs):
"""Execute the cmd passed as arg
@@ -131,6 +107,8 @@ class BashFeature(Feature):
proc = subprocess.Popen(cmd.split(), stdout=f_stdout,
stderr=subprocess.STDOUT)
ret = proc.wait()
+ self.__logger.info(
+ "Test result is stored in '%s'", self.result_file)
if ret != 0:
self.__logger.error("Execute command: %s failed", cmd)
except KeyError: