From a43eaa4d43c3ca2e3cd61ff0033dee2da2f1b23a Mon Sep 17 00:00:00 2001 From: Sergey Kraynev Date: Thu, 21 Jul 2016 11:45:41 +0300 Subject: [PATCH] Run unittests via tox - Add "units" section to tox.ini file - Add .tox to ignore file to ignore results of tests by git - Fix unittest to use unittests library Change-Id: Icffc9211eff2f6f54e24369b11a7c4c45b3dda98 --- .gitignore | 5 ++++- tox.ini | 4 ++++ unittests/__init__.py | 0 unittests/test_namespaces.py | 19 ++++++------------- 4 files changed, 14 insertions(+), 14 deletions(-) create mode 100644 unittests/__init__.py diff --git a/.gitignore b/.gitignore index e70c7f1..c463a60 100644 --- a/.gitignore +++ b/.gitignore @@ -37,5 +37,8 @@ tools/lintstack.head.py tools/pylint_exceptions *.zip -#Linux swap file +# Linux swap file *.swp + +# Tests results +.tox diff --git a/tox.ini b/tox.ini index ba29b4f..5d75a15 100644 --- a/tox.ini +++ b/tox.ini @@ -31,3 +31,7 @@ deps= ipdb -r{toxinidir}/test-requirements.txt commands = python -m unittest tests.test_cicd_apps.MuranoCiCdTest.test_deploy_cicd + +[testenv:units] +# FIXME! +commands = python -m unittest unittests.test_namespaces.TestNamespaces.test_namespaces diff --git a/unittests/__init__.py b/unittests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/unittests/test_namespaces.py b/unittests/test_namespaces.py index 599a56e..2537507 100644 --- a/unittests/test_namespaces.py +++ b/unittests/test_namespaces.py @@ -2,8 +2,10 @@ import os import re import yaml +import testtools -class TestNamespaces(): + +class TestNamespaces(testtools.TestCase): def get_list_of_classes(self): # TODO: should be fixed future with some common approach for all tests root_dir = os.path.dirname(os.path.abspath(__file__)).rsplit('/', 1)[0] @@ -63,16 +65,7 @@ class TestNamespaces(): for ns in self.get_namespaces(cls_name): self.check_name(ns, cls_name, error_list) - if error_list: - error_string = "\n".join(error_list) - msg = "Test detects follow list of errors: \n%s" % error_string - raise ValueError(msg) + error_string = "\n".join(error_list) + msg = "Test detects follow list of errors: \n%s" % error_string - -def main(): - test = TestNamespaces() - test.test_namespaces() - -# to run test just execute command: -# python unittests/test_namespaces.py -main() + self.assertEqual(0, len(error_list), msg)