aboutsummaryrefslogtreecommitdiffstats
path: root/functest/tests/unit/cli
diff options
context:
space:
mode:
authorCédric Ollivier <cedric.ollivier@orange.com>2017-05-18 19:37:26 +0200
committerCédric Ollivier <cedric.ollivier@orange.com>2017-05-18 20:14:41 +0200
commited88e5e9abb8c24cee2507b62a45878637411c25 (patch)
treed395423186a037b68796a942e9e3f5ece8c73369 /functest/tests/unit/cli
parent510a5cfda3b375b432e0ed17a61e34de969b520c (diff)
Modify how to disable logging in unit test.
Logs are only disabled when the unit tests are run from cmdline. It allows running them via pytest_suite_runner.py and printing their results to functest.log. You should notice that the unit test must disable the logger of the tested TestCase (e.g. testcase.TestCase.logger.disabled = 1). Otherwise false logs will be printed in console. Change-Id: Ic171e4575c8bab2e52db1897ae026b61a03b6247 Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
Diffstat (limited to 'functest/tests/unit/cli')
-rw-r--r--functest/tests/unit/cli/commands/test_cli_env.py3
-rw-r--r--functest/tests/unit/cli/commands/test_cli_os.py2
-rw-r--r--functest/tests/unit/cli/commands/test_cli_testcase.py3
-rw-r--r--functest/tests/unit/cli/commands/test_cli_tier.py3
-rw-r--r--functest/tests/unit/cli/test_cli_base.py3
5 files changed, 5 insertions, 9 deletions
diff --git a/functest/tests/unit/cli/commands/test_cli_env.py b/functest/tests/unit/cli/commands/test_cli_env.py
index 4b6ea57a..def30aa1 100644
--- a/functest/tests/unit/cli/commands/test_cli_env.py
+++ b/functest/tests/unit/cli/commands/test_cli_env.py
@@ -18,8 +18,6 @@ from functest.tests.unit import test_utils
class CliEnvTesting(unittest.TestCase):
- logging.disable(logging.CRITICAL)
-
def setUp(self):
self.cli_environ = cli_env.CliEnv()
@@ -127,4 +125,5 @@ class CliEnvTesting(unittest.TestCase):
if __name__ == "__main__":
+ logging.disable(logging.CRITICAL)
unittest.main(verbosity=2)
diff --git a/functest/tests/unit/cli/commands/test_cli_os.py b/functest/tests/unit/cli/commands/test_cli_os.py
index f0e58c67..9c576fe4 100644
--- a/functest/tests/unit/cli/commands/test_cli_os.py
+++ b/functest/tests/unit/cli/commands/test_cli_os.py
@@ -18,7 +18,6 @@ from functest.utils.constants import CONST
class CliOpenStackTesting(unittest.TestCase):
- logging.disable(logging.CRITICAL)
def setUp(self):
self.endpoint_ip = 'test_ip'
@@ -235,4 +234,5 @@ class CliOpenStackTesting(unittest.TestCase):
if __name__ == "__main__":
+ logging.disable(logging.CRITICAL)
unittest.main(verbosity=2)
diff --git a/functest/tests/unit/cli/commands/test_cli_testcase.py b/functest/tests/unit/cli/commands/test_cli_testcase.py
index 39c8139d..4bf808bf 100644
--- a/functest/tests/unit/cli/commands/test_cli_testcase.py
+++ b/functest/tests/unit/cli/commands/test_cli_testcase.py
@@ -17,8 +17,6 @@ from functest.utils.constants import CONST
class CliTestCasesTesting(unittest.TestCase):
- logging.disable(logging.CRITICAL)
-
def setUp(self):
self.testname = 'testname'
with mock.patch('functest.cli.commands.cli_testcase.tb'):
@@ -100,4 +98,5 @@ class CliTestCasesTesting(unittest.TestCase):
if __name__ == "__main__":
+ logging.disable(logging.CRITICAL)
unittest.main(verbosity=2)
diff --git a/functest/tests/unit/cli/commands/test_cli_tier.py b/functest/tests/unit/cli/commands/test_cli_tier.py
index 802359f1..abcdc597 100644
--- a/functest/tests/unit/cli/commands/test_cli_tier.py
+++ b/functest/tests/unit/cli/commands/test_cli_tier.py
@@ -17,8 +17,6 @@ from functest.utils.constants import CONST
class CliTierTesting(unittest.TestCase):
- logging.disable(logging.CRITICAL)
-
def setUp(self):
self.tiername = 'tiername'
self.testnames = 'testnames'
@@ -127,4 +125,5 @@ class CliTierTesting(unittest.TestCase):
if __name__ == "__main__":
+ logging.disable(logging.CRITICAL)
unittest.main(verbosity=2)
diff --git a/functest/tests/unit/cli/test_cli_base.py b/functest/tests/unit/cli/test_cli_base.py
index fe065c2a..89603279 100644
--- a/functest/tests/unit/cli/test_cli_base.py
+++ b/functest/tests/unit/cli/test_cli_base.py
@@ -22,8 +22,6 @@ with mock.patch('functest.cli.commands.cli_testcase.CliTestcase.__init__',
class CliBaseTesting(unittest.TestCase):
- logging.disable(logging.CRITICAL)
-
def setUp(self):
self.runner = CliRunner()
self._openstack = cli_base._openstack
@@ -135,4 +133,5 @@ class CliBaseTesting(unittest.TestCase):
if __name__ == "__main__":
+ logging.disable(logging.CRITICAL)
unittest.main(verbosity=2)