aboutsummaryrefslogtreecommitdiffstats
path: root/functest
diff options
context:
space:
mode:
authorJose Lausuch <jose.lausuch@ericsson.com>2017-05-18 18:31:52 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-05-18 18:31:52 +0000
commitdd9fb78e0553c35eb60e76b2979dac803f818ecb (patch)
tree86824027bf8ae89359c6ccbd546827ffad37c89a /functest
parent6a655e830dd891d0b5afec601b4fb2461b1fad42 (diff)
parent510a5cfda3b375b432e0ed17a61e34de969b520c (diff)
Merge "Use logger instead of printing in console"
Diffstat (limited to 'functest')
-rw-r--r--functest/core/pytest_suite_runner.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/functest/core/pytest_suite_runner.py b/functest/core/pytest_suite_runner.py
index 0dd860d2..a6e47660 100644
--- a/functest/core/pytest_suite_runner.py
+++ b/functest/core/pytest_suite_runner.py
@@ -8,8 +8,10 @@
# pylint: disable=missing-docstring
import logging
-import unittest
import time
+import unittest
+
+import six
from functest.core import testcase
@@ -19,6 +21,7 @@ class PyTestSuiteRunner(testcase.TestCase):
This superclass is designed to execute pre-configured unittest.TestSuite()
objects
"""
+
def __init__(self, **kwargs):
super(PyTestSuiteRunner, self).__init__(**kwargs)
self.suite = None
@@ -30,11 +33,18 @@ class PyTestSuiteRunner(testcase.TestCase):
"""
try:
name = kwargs["name"]
- self.suite = unittest.TestLoader().loadTestsFromName(name)
+ try:
+ self.suite = unittest.TestLoader().loadTestsFromName(name)
+ except ImportError:
+ self.logger.error("Can not import %s", name)
+ return testcase.TestCase.EX_RUN_ERROR
except KeyError:
pass
self.start_time = time.time()
- result = unittest.TextTestRunner(verbosity=2).run(self.suite)
+ stream = six.StringIO()
+ result = unittest.TextTestRunner(
+ stream=stream, verbosity=2).run(self.suite)
+ self.logger.debug("\n\n%s", stream.getvalue())
self.stop_time = time.time()
if result.errors: