Rename test/unit/cmd directory 49/48749/2
authorRoss Brattain <ross.b.brattain@intel.com>
Mon, 14 Aug 2017 16:54:51 +0000 (09:54 -0700)
committerRodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
Thu, 21 Dec 2017 14:12:58 +0000 (14:12 +0000)
Renamed test/unit/cmd directory to test/unit/test_cmd, in order to
avoid importing errors during the execution of unit tests. This directory
name collides with Python "cmd" library.

Change-Id: Ie06d58d4faace33df684c8e511a398aa0667b098
Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
tests/unit/test_cmd/__init__.py [moved from tests/unit/cmd/__init__.py with 100% similarity]
tests/unit/test_cmd/commands/__init__.py [moved from tests/unit/cmd/commands/__init__.py with 100% similarity]
tests/unit/test_cmd/commands/test_env.py [moved from tests/unit/cmd/commands/test_env.py with 90% similarity]
tests/unit/test_cmd/commands/test_testcase.py [moved from tests/unit/cmd/commands/test_testcase.py with 100% similarity]
tests/unit/test_cmd/test_NSBperf.py [moved from tests/unit/cmd/test_NSBperf.py with 99% similarity]

similarity index 90%
rename from tests/unit/cmd/commands/test_env.py
rename to tests/unit/test_cmd/commands/test_env.py
index 73cd5af..13c3ed4 100644 (file)
@@ -49,6 +49,9 @@ class EnvCommandTestCase(unittest.TestCase):
     @mock.patch('yardstick.cmd.commands.env.HttpClient.get')
     @mock.patch('yardstick.cmd.commands.env.EnvCommand._print_status')
     def test_check_status(self, print_mock, get_mock):
+        # pylint: disable=unused-argument
+        # NOTE(ralonsoh): the pylint exception must be removed. The mocked
+        # command call must be tested.
         task_id = str(uuid.uuid4())
         get_mock.return_value = {'status': 2, 'result': 'error'}
         status = EnvCommand()._check_status(task_id, 'hello world')
@@ -57,7 +60,8 @@ class EnvCommandTestCase(unittest.TestCase):
     def test_print_status(self):
         try:
             EnvCommand()._print_status('hello', 'word')
-        except Exception as e:
+        except Exception as e:  # pylint: disable=broad-except
+            # NOTE(ralonsoh): try to reduce the scope of this exception.
             self.assertIsInstance(e, IndexError)
 
 
similarity index 99%
rename from tests/unit/cmd/test_NSBperf.py
rename to tests/unit/test_cmd/test_NSBperf.py
index e1b4da7..19eb0af 100644 (file)
@@ -27,7 +27,8 @@ from yardstick.cmd import NSBperf
 
 @mock.patch('six.moves.input', return_value='0')
 class TestHandler(unittest.TestCase):
-    def test_handler(self, test):
+
+    def test_handler(self, *args):
         subprocess.call = mock.Mock(return_value=0)
         self.assertRaises(SystemExit, NSBperf.sigint_handler)