Remove print out of logger exception in TestUtils 91/58791/2
authorRodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
Thu, 7 Jun 2018 16:50:30 +0000 (17:50 +0100)
committerEmma Foley <emma.l.foley@intel.com>
Wed, 20 Jun 2018 12:57:09 +0000 (12:57 +0000)
Remove print out of logger exception while executing
"TestUtils.test_parse_ini_file_missing_section_header" test case.

JIRA: YARDSTICK-1225

Change-Id: I2a4e447c5d119fb9585b477d74f3d0a002c8278e
Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
(cherry picked from commit 99d51230daac3452f5295b4ea39890d8920e6ca3)

yardstick/tests/unit/common/test_utils.py

index 9540a39..74c6918 100644 (file)
@@ -893,7 +893,7 @@ class TestUtils(unittest.TestCase):
         os.environ.clear()
         os.environ.update(base_env)
 
-    @mock.patch('yardstick.common.utils.configparser.ConfigParser')
+    @mock.patch.object(configparser, 'ConfigParser')
     def test_parse_ini_file(self, mock_config_parser_type):
         defaults = {
             'default1': 'value1',
@@ -925,23 +925,26 @@ class TestUtils(unittest.TestCase):
         result = utils.parse_ini_file('my_path')
         self.assertDictEqual(result, expected)
 
-    @mock.patch('yardstick.common.utils.configparser.ConfigParser')
-    def test_parse_ini_file_missing_section_header(self, mock_config_parser_type):
+    @mock.patch.object(utils, 'logger')
+    @mock.patch.object(configparser, 'ConfigParser')
+    def test_parse_ini_file_missing_section_header(
+            self, mock_config_parser_type, *args):
         mock_config_parser = mock_config_parser_type()
-        mock_config_parser.read.side_effect = \
-            configparser.MissingSectionHeaderError(mock.Mock(), 321, mock.Mock())
+        mock_config_parser.read.side_effect = (
+            configparser.MissingSectionHeaderError(mock.Mock(), 321,
+                                                   mock.Mock()))
 
         with self.assertRaises(configparser.MissingSectionHeaderError):
             utils.parse_ini_file('my_path')
 
-    @mock.patch('yardstick.common.utils.configparser.ConfigParser')
+    @mock.patch.object(configparser, 'ConfigParser')
     def test_parse_ini_file_no_file(self, mock_config_parser_type):
         mock_config_parser = mock_config_parser_type()
         mock_config_parser.read.return_value = False
         with self.assertRaises(RuntimeError):
             utils.parse_ini_file('my_path')
 
-    @mock.patch('yardstick.common.utils.configparser.ConfigParser')
+    @mock.patch.object(configparser, 'ConfigParser')
     def test_parse_ini_file_no_default_section_header(self, mock_config_parser_type):
         s1 = {
             'key1': 'value11',