Fix many pylint warnings 75/53475/1
authorCédric Ollivier <cedric.ollivier@orange.com>
Sun, 11 Mar 2018 18:16:09 +0000 (19:16 +0100)
committerCédric Ollivier <cedric.ollivier@orange.com>
Sun, 11 Mar 2018 19:06:54 +0000 (20:06 +0100)
Only pylint warnings in vnf modules has to be fixed now.

Change-Id: Ie71230072a51bb72ec0b1d4fef2652494d29948e
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
functest/api/base.py
functest/api/resources/v1/envs.py
functest/api/resources/v1/tiers.py
functest/api/server.py
functest/opnfv_tests/openstack/rally/rally.py
functest/opnfv_tests/vnf/ims/ixia/utils/IxLoadUtils.py
functest/opnfv_tests/vnf/router/utilvnf.py
functest/tests/unit/utils/test_functest_utils.py
tox.ini

index 75f059b..b104829 100644 (file)
@@ -26,9 +26,6 @@ LOGGER = logging.getLogger(__name__)
 class ApiResource(Resource):
     """ API Resource class"""
 
-    def __init__(self):
-        super(ApiResource, self).__init__()
-
     def _post_args(self):  # pylint: disable=no-self-use
         # pylint: disable=maybe-no-member
         """ Return action and args after parsing request """
index 3e6f05a..d808ae3 100644 (file)
 Resources to handle environment related requests
 """
 
-import pkg_resources
 import socket
 
 import IPy
 from flask import jsonify
 from flasgger.utils import swag_from
+import pkg_resources
 
 from functest.api.base import ApiResource
 from functest.api.common import api_utils
index 523df13..5854042 100644 (file)
 Resources to handle tier related requests
 """
 
-import pkg_resources
 import re
 
 from flask import jsonify
 from flasgger.utils import swag_from
+import pkg_resources
 
 from functest.api.base import ApiResource
 from functest.api.common import api_utils
index 3200c1a..2a6b228 100644 (file)
@@ -89,7 +89,7 @@ def init_db():
         except TypeError:
             pass
         return False
-    # pylint: disable=bad-builtin
+    # pylint: disable=bad-option-value,bad-builtin,
     subclses = filter(func, inspect.getmembers(models, inspect.isclass))
     LOGGER.debug('Import models: %s', [subcls[1] for subcls in subclses])
     BASE.metadata.create_all(bind=ENGINE)
index f9fb7b8..1502d58 100644 (file)
@@ -189,7 +189,7 @@ class RallyBase(testcase.TestCase):
                 return False
 
             for result in report.get('result'):
-                if result is None or len(result.get('error')) > 0:
+                if result is None or result.get('error'):
                     return False
 
         return True
index 50dfbc6..bc71a38 100644 (file)
@@ -7,11 +7,12 @@
 # which accompanies this distribution, and is available at
 # http://www.apache.org/licenses/LICENSE-2.0
 
-import requests
 import sys
 import time
 import logging
 
+import requests
+
 from functest.opnfv_tests.vnf.ims.ixia.utils import IxRestUtils
 
 
index 6861b38..2865175 100644 (file)
@@ -20,7 +20,6 @@ import yaml
 
 from functest.utils import config
 from git import Repo
-from requests.auth import HTTPBasicAuth
 from snaps.openstack.utils import nova_utils
 
 
@@ -175,7 +174,7 @@ class Utilvnf(object):  # pylint: disable=too-many-instance-attributes
 
         response = requests.get(
             url,
-            auth=HTTPBasicAuth('admin', 'admin'),
+            auth=requests.auth.HTTPBasicAuth('admin', 'admin'),
             headers={'Tenant': 'default_tenant'})
 
         resp_data = response.json()
index 77328fd..d35ed8c 100644 (file)
@@ -20,6 +20,7 @@ from functest.utils import functest_utils
 
 
 class FunctestUtilsTesting(unittest.TestCase):
+    # pylint: disable=too-many-instance-attributes
 
     readline = 0
     test_ip = ['10.1.23.4', '10.1.14.15', '10.1.16.15']
@@ -90,8 +91,8 @@ class FunctestUtilsTesting(unittest.TestCase):
 
     @mock.patch('functest.utils.functest_utils.LOGGER.error')
     @mock.patch('functest.utils.functest_utils.LOGGER.info')
-    def test_execute_command_args_present_with_error(self, mock_logger_info,
-                                                     mock_logger_error):
+    def test_exec_cmd_args_present_ko(self, mock_logger_info,
+                                      mock_logger_error):
         with mock.patch('functest.utils.functest_utils.subprocess.Popen') \
                 as mock_subproc_open, \
                 mock.patch('six.moves.builtins.open',
@@ -120,8 +121,7 @@ class FunctestUtilsTesting(unittest.TestCase):
             mock_logger_error.assert_called_once_with(self.error_msg)
 
     @mock.patch('functest.utils.functest_utils.LOGGER.info')
-    def test_execute_command_args_present_with_success(self, mock_logger_info,
-                                                       ):
+    def test_exec_cmd_args_present_ok(self, mock_logger_info):
         with mock.patch('functest.utils.functest_utils.subprocess.Popen') \
                 as mock_subproc_open, \
                 mock.patch('six.moves.builtins.open',
@@ -149,7 +149,8 @@ class FunctestUtilsTesting(unittest.TestCase):
             mopen.assert_called_once_with(self.output_file, "w")
 
     @mock.patch('sys.stdout')
-    def test_execute_command_args_missing_with_success(self, stdout=None):
+    def test_exec_cmd_args_missing_ok(self, stdout=None):
+        # pylint: disable=unused-argument
         with mock.patch('functest.utils.functest_utils.subprocess.Popen') \
                 as mock_subproc_open:
 
@@ -172,7 +173,8 @@ class FunctestUtilsTesting(unittest.TestCase):
             self.assertEqual(resp, 0)
 
     @mock.patch('sys.stdout')
-    def test_execute_command_args_missing_with_error(self, stdout=None):
+    def test_exec_cmd_args_missing_ko(self, stdout=None):
+        # pylint: disable=unused-argument
         with mock.patch('functest.utils.functest_utils.subprocess.Popen') \
                 as mock_subproc_open:
 
@@ -193,7 +195,7 @@ class FunctestUtilsTesting(unittest.TestCase):
                                                   output_file=None)
             self.assertEqual(resp, 1)
 
-    def test_get_parameter_from_yaml_failed(self):
+    def test_get_param_from_yaml_failed(self):
         self.file_yaml['general'] = None
         with mock.patch('six.moves.builtins.open', mock.mock_open()), \
                 mock.patch('functest.utils.functest_utils.yaml.safe_load') \
@@ -206,7 +208,7 @@ class FunctestUtilsTesting(unittest.TestCase):
                              " defined in config_functest.yaml" %
                              self.parameter) in excep.exception)
 
-    def test_get_parameter_from_yaml_default(self):
+    def test_get_param_from_yaml_def(self):
         with mock.patch('six.moves.builtins.open', mock.mock_open()), \
                 mock.patch('functest.utils.functest_utils.yaml.safe_load') \
                 as mock_yaml:
diff --git a/tox.ini b/tox.ini
index 8b74f46..8311582 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -48,13 +48,14 @@ modules =
   functest.tests.unit.openstack.tempest
   functest.tests.unit.openstack.vping
   functest.tests.unit.vnf.router
+  functest.tests.unit.utils
   functest.utils.config
   functest.utils.constants
   functest.utils.env
   functest.utils.functest_utils
 commands =
   bash -c "\
-    pylint -f parseable --disable=locally-disabled functest | \
+    pylint -f parseable --ignore-imports=y --disable=locally-disabled functest | \
     tee pylint.out | sed -ne '/Raw metrics/,//p'"
   pylint --reports=n --errors-only functest
   pylint --disable=locally-disabled --ignore-imports=y --reports=n {[testenv:pylint]modules}