From eb973db776e77781c875d2640c4d59f878ba27c0 Mon Sep 17 00:00:00 2001 From: Cédric Ollivier Date: Sun, 11 Mar 2018 19:16:09 +0100 Subject: Fix many pylint warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Only pylint warnings in vnf modules has to be fixed now. Change-Id: Ie71230072a51bb72ec0b1d4fef2652494d29948e Signed-off-by: Cédric Ollivier --- functest/api/base.py | 3 --- functest/api/resources/v1/envs.py | 2 +- functest/api/resources/v1/tiers.py | 2 +- functest/api/server.py | 2 +- functest/opnfv_tests/openstack/rally/rally.py | 2 +- functest/opnfv_tests/vnf/ims/ixia/utils/IxLoadUtils.py | 3 ++- functest/opnfv_tests/vnf/router/utilvnf.py | 3 +-- functest/tests/unit/utils/test_functest_utils.py | 18 ++++++++++-------- tox.ini | 3 ++- 9 files changed, 19 insertions(+), 19 deletions(-) diff --git a/functest/api/base.py b/functest/api/base.py index 75f059b74..b10482931 100644 --- a/functest/api/base.py +++ b/functest/api/base.py @@ -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 """ diff --git a/functest/api/resources/v1/envs.py b/functest/api/resources/v1/envs.py index 3e6f05ac9..d808ae3c9 100644 --- a/functest/api/resources/v1/envs.py +++ b/functest/api/resources/v1/envs.py @@ -10,12 +10,12 @@ 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 diff --git a/functest/api/resources/v1/tiers.py b/functest/api/resources/v1/tiers.py index 523df130e..58540425b 100644 --- a/functest/api/resources/v1/tiers.py +++ b/functest/api/resources/v1/tiers.py @@ -11,11 +11,11 @@ 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 diff --git a/functest/api/server.py b/functest/api/server.py index 3200c1a2f..2a6b228ff 100644 --- a/functest/api/server.py +++ b/functest/api/server.py @@ -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) diff --git a/functest/opnfv_tests/openstack/rally/rally.py b/functest/opnfv_tests/openstack/rally/rally.py index f9fb7b8a4..1502d5825 100644 --- a/functest/opnfv_tests/openstack/rally/rally.py +++ b/functest/opnfv_tests/openstack/rally/rally.py @@ -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 diff --git a/functest/opnfv_tests/vnf/ims/ixia/utils/IxLoadUtils.py b/functest/opnfv_tests/vnf/ims/ixia/utils/IxLoadUtils.py index 50dfbc661..bc71a38cf 100644 --- a/functest/opnfv_tests/vnf/ims/ixia/utils/IxLoadUtils.py +++ b/functest/opnfv_tests/vnf/ims/ixia/utils/IxLoadUtils.py @@ -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 diff --git a/functest/opnfv_tests/vnf/router/utilvnf.py b/functest/opnfv_tests/vnf/router/utilvnf.py index 6861b3865..2865175b3 100644 --- a/functest/opnfv_tests/vnf/router/utilvnf.py +++ b/functest/opnfv_tests/vnf/router/utilvnf.py @@ -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() diff --git a/functest/tests/unit/utils/test_functest_utils.py b/functest/tests/unit/utils/test_functest_utils.py index 77328fda8..d35ed8ced 100644 --- a/functest/tests/unit/utils/test_functest_utils.py +++ b/functest/tests/unit/utils/test_functest_utils.py @@ -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 8b74f46bf..8311582e7 100644 --- 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} -- cgit 1.2.3-korg