aboutsummaryrefslogtreecommitdiffstats
path: root/functest/core
diff options
context:
space:
mode:
Diffstat (limited to 'functest/core')
-rw-r--r--functest/core/feature.py1
-rw-r--r--functest/core/pytest_suite_runner.py18
-rw-r--r--functest/core/testcase.py16
3 files changed, 22 insertions, 13 deletions
diff --git a/functest/core/feature.py b/functest/core/feature.py
index 8563c925..140c9bb2 100644
--- a/functest/core/feature.py
+++ b/functest/core/feature.py
@@ -83,7 +83,6 @@ class Feature(base.TestCase):
ft_utils.logger_test_results(
self.project_name, self.case_name,
self.result, self.details)
- self.__logger.info("%s %s", self.project_name, self.result)
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)
diff --git a/functest/core/pytest_suite_runner.py b/functest/core/pytest_suite_runner.py
index 21edc187..2b201ee0 100644
--- a/functest/core/pytest_suite_runner.py
+++ b/functest/core/pytest_suite_runner.py
@@ -5,12 +5,18 @@
#
# http://www.apache.org/licenses/LICENSE-2.0
-import testcase as base
+# pylint: disable=missing-docstring
+
+import logging
import unittest
import time
+from functest.core import testcase
+
+logging.basicConfig()
+
-class PyTestSuiteRunner(base.TestCase):
+class PyTestSuiteRunner(testcase.TestCase):
"""
This superclass is designed to execute pre-configured unittest.TestSuite()
objects
@@ -18,7 +24,7 @@ class PyTestSuiteRunner(base.TestCase):
def __init__(self, **kwargs):
super(PyTestSuiteRunner, self).__init__(**kwargs)
self.suite = None
- self.logger = None
+ self.logger = logging.getLogger(__name__)
def run(self, **kwargs):
"""
@@ -45,13 +51,13 @@ class PyTestSuiteRunner(base.TestCase):
# we shall distinguish Execution Error from FAIL results
# TestCase.EX_RUN_ERROR means that the test case was not run
# not that it was run but the result was FAIL
- exit_code = base.TestCase.EX_OK
+ exit_code = testcase.TestCase.EX_OK
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.logger.info("%s FAILED", self.case_name)
self.result = 'FAIL'
else:
- self.logger.info("%s OK" % self.case_name)
+ self.logger.info("%s OK", self.case_name)
self.result = 'PASS'
self.details = {}
diff --git a/functest/core/testcase.py b/functest/core/testcase.py
index 49fae609..d8b63ef2 100644
--- a/functest/core/testcase.py
+++ b/functest/core/testcase.py
@@ -12,6 +12,8 @@
import logging
import os
+import prettytable
+
import functest.utils.functest_utils as ft_utils
__author__ = "Cedric Ollivier <cedric.ollivier@orange.com>"
@@ -49,14 +51,16 @@ class TestCase(object):
assert self.case_name
result = 'PASS' if(self.is_successful(
) == TestCase.EX_OK) else 'FAIL'
- return ('| {0:<23} | {1:<13} | {2:<10} | {3:<13} |'
- '\n{4:-<26}{4:-<16}{4:-<13}{4:-<16}{4}'.format(
- self.case_name, self.project_name,
- self.get_duration(), result, '+'))
+ msg = prettytable.PrettyTable(
+ header_style='upper', padding_width=5,
+ field_names=['test case', 'project', 'duration',
+ 'result'])
+ msg.add_row([self.case_name, self.project_name,
+ self.get_duration(), result])
+ return msg.get_string()
except AssertionError:
self.__logger.error("We cannot print invalid objects")
- return '| {0:^68} |\n{1:-<26}{1:-<16}{1:-<13}{1:-<16}{1}'.format(
- 'INVALID OBJECT', '+')
+ return super(TestCase, self).__str__()
def get_duration(self):
"""Return the duration of the test case.