From a1a85f7cc121b1c1176f2b79b22f4e4bca43177a Mon Sep 17 00:00:00 2001 From: Cédric Ollivier Date: Tue, 19 Jun 2018 07:14:42 +0200 Subject: Fix pylint errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit They are highlighted by the last pylint version. Change-Id: I473212a413013492716993fb536903b13bff66ed Signed-off-by: Cédric Ollivier --- functest/opnfv_tests/openstack/rally/rally.py | 8 ++++---- functest/opnfv_tests/openstack/snaps/health_check.py | 6 +++--- functest/opnfv_tests/openstack/snaps/snaps_utils.py | 9 +++++---- functest/opnfv_tests/sdn/odl/odl.py | 2 +- functest/opnfv_tests/vnf/router/cloudify_vrouter.py | 20 +++++++------------- functest/opnfv_tests/vnf/router/utilvnf.py | 8 ++++---- .../vnf/router/vnf_controller/vm_controller.py | 6 +++--- functest/opnfv_tests/vnf/router/vrouter_base.py | 6 +++--- functest/tests/unit/odl/test_odl.py | 2 ++ test-requirements.txt | 2 +- tox.ini | 5 +++-- 11 files changed, 36 insertions(+), 38 deletions(-) diff --git a/functest/opnfv_tests/openstack/rally/rally.py b/functest/opnfv_tests/openstack/rally/rally.py index cca198853..c3c53fbca 100644 --- a/functest/opnfv_tests/openstack/rally/rally.py +++ b/functest/opnfv_tests/openstack/rally/rally.py @@ -286,7 +286,7 @@ class RallyBase(testcase.TestCase): self.excl_scenario())) if black_tests: - LOGGER.debug("Blacklisted tests: " + str(black_tests)) + LOGGER.debug("Blacklisted tests: %s", str(black_tests)) include = True for cases_line in cases_file: @@ -358,9 +358,9 @@ class RallyBase(testcase.TestCase): # parse JSON operation result if self.task_succeed(json_results): - LOGGER.info('Test scenario: "{}" OK.'.format(test_name) + "\n") + LOGGER.info('Test scenario: "%s" OK.', test_name) else: - LOGGER.info('Test scenario: "{}" Failed.'.format(test_name) + "\n") + LOGGER.info('Test scenario: "%s" Failed.', test_name) def _run_task(self, test_name): """Run a task.""" @@ -369,7 +369,7 @@ class RallyBase(testcase.TestCase): task_file = os.path.join(self.RALLY_DIR, 'task.yaml') if not os.path.exists(task_file): LOGGER.error("Task file '%s' does not exist.", task_file) - raise Exception("Task file '%s' does not exist.", task_file) + raise Exception("Task file '{}' does not exist.".format(task_file)) file_name = self._prepare_test_list(test_name) if self.file_is_empty(file_name): diff --git a/functest/opnfv_tests/openstack/snaps/health_check.py b/functest/opnfv_tests/openstack/snaps/health_check.py index 8a88ac6b8..3a9c821d2 100644 --- a/functest/opnfv_tests/openstack/snaps/health_check.py +++ b/functest/opnfv_tests/openstack/snaps/health_check.py @@ -12,12 +12,12 @@ import unittest +from snaps.openstack.tests.create_instance_tests import SimpleHealthCheck +from snaps.openstack.tests.os_source_file_test import OSIntegrationTestCase + from functest.opnfv_tests.openstack.snaps.snaps_test_runner import ( SnapsTestRunner) -from snaps.openstack.tests.os_source_file_test import OSIntegrationTestCase -from snaps.openstack.tests.create_instance_tests import SimpleHealthCheck - class HealthCheck(SnapsTestRunner): """ diff --git a/functest/opnfv_tests/openstack/snaps/snaps_utils.py b/functest/opnfv_tests/openstack/snaps/snaps_utils.py index fa1005ea8..21d1dd60d 100644 --- a/functest/opnfv_tests/openstack/snaps/snaps_utils.py +++ b/functest/opnfv_tests/openstack/snaps/snaps_utils.py @@ -7,15 +7,16 @@ # # http://www.apache.org/licenses/LICENSE-2.0 -"""Some common utils wrapping snaps functions """ +"""Some common utils wrapping snaps functions""" + +from snaps.openstack.tests import openstack_tests +from snaps.openstack.utils import neutron_utils +from snaps.openstack.utils import nova_utils from functest.utils import config from functest.utils import constants from functest.utils import env -from snaps.openstack.tests import openstack_tests -from snaps.openstack.utils import neutron_utils, nova_utils - def get_ext_net_name(os_creds): """ diff --git a/functest/opnfv_tests/sdn/odl/odl.py b/functest/opnfv_tests/sdn/odl/odl.py index cb086a30e..180fa0eab 100644 --- a/functest/opnfv_tests/sdn/odl/odl.py +++ b/functest/opnfv_tests/sdn/odl/odl.py @@ -27,10 +27,10 @@ import sys import os_client_config from six.moves import urllib +from xtesting.core import robotframework from functest.utils import config from functest.utils import env -from xtesting.core import robotframework __author__ = "Cedric Ollivier " diff --git a/functest/opnfv_tests/vnf/router/cloudify_vrouter.py b/functest/opnfv_tests/vnf/router/cloudify_vrouter.py index c5c72e05c..a88200339 100644 --- a/functest/opnfv_tests/vnf/router/cloudify_vrouter.py +++ b/functest/opnfv_tests/vnf/router/cloudify_vrouter.py @@ -19,14 +19,7 @@ import uuid from cloudify_rest_client import CloudifyClient from cloudify_rest_client.executions import Execution from scp import SCPClient - -from functest.opnfv_tests.openstack.snaps import snaps_utils -import functest.opnfv_tests.vnf.router.vrouter_base as vrouter_base -from functest.opnfv_tests.vnf.router.utilvnf import Utilvnf -from functest.utils import config -from functest.utils import env -from functest.utils import functest_utils - +import six from snaps.config.flavor import FlavorConfig from snaps.config.image import ImageConfig from snaps.config.keypair import KeypairConfig @@ -36,7 +29,6 @@ from snaps.config.security_group import ( Direction, Protocol, SecurityGroupConfig, SecurityGroupRuleConfig) from snaps.config.user import UserConfig from snaps.config.vm_inst import FloatingIpConfig, VmInstanceConfig - from snaps.openstack.create_flavor import OpenStackFlavor from snaps.openstack.create_image import OpenStackImage from snaps.openstack.create_instance import OpenStackVmInstance @@ -45,13 +37,15 @@ from snaps.openstack.create_network import OpenStackNetwork from snaps.openstack.create_security_group import OpenStackSecurityGroup from snaps.openstack.create_router import OpenStackRouter from snaps.openstack.create_user import OpenStackUser - import snaps.openstack.utils.glance_utils as glance_utils from snaps.openstack.utils import keystone_utils - -import six - +from functest.opnfv_tests.openstack.snaps import snaps_utils +import functest.opnfv_tests.vnf.router.vrouter_base as vrouter_base +from functest.opnfv_tests.vnf.router.utilvnf import Utilvnf +from functest.utils import config +from functest.utils import env +from functest.utils import functest_utils __author__ = "Shuya Nakama " diff --git a/functest/opnfv_tests/vnf/router/utilvnf.py b/functest/opnfv_tests/vnf/router/utilvnf.py index 2865175b3..31e1b9196 100644 --- a/functest/opnfv_tests/vnf/router/utilvnf.py +++ b/functest/opnfv_tests/vnf/router/utilvnf.py @@ -18,10 +18,10 @@ import pkg_resources import requests import yaml -from functest.utils import config from git import Repo from snaps.openstack.utils import nova_utils +from functest.utils import config RESULT_SPRIT_INDEX = { "transfer": 8, @@ -202,12 +202,12 @@ class Utilvnf(object): # pylint: disable=too-many-instance-attributes def request_vnf_reboot(self, vnf_info_list): for vnf in vnf_info_list: - self.logger.debug("reboot the " + vnf["vnf_name"]) + self.logger.debug("reboot the %s", vnf["vnf_name"]) self.reboot_vm(vnf["vnf_name"]) def request_vm_delete(self, vnf_info_list): for vnf in vnf_info_list: - self.logger.debug("delete the " + vnf["vnf_name"]) + self.logger.debug("delete the %s", vnf["vnf_name"]) self.delete_vm(vnf["vnf_name"]) def get_vnf_info_list(self, cfy_manager_ip, topology_deploy_name, @@ -225,7 +225,7 @@ class Utilvnf(object): # pylint: disable=too-many-instance-attributes vnf["target_vnf_flag"] = bool(vnf_name == target_vnf_name) - self.logger.debug("vnf name : " + vnf_name) + self.logger.debug("vnf name : %s", vnf_name) self.logger.debug(vnf_name + " floating ip address : " + vnf["floating_ip"]) diff --git a/functest/opnfv_tests/vnf/router/vnf_controller/vm_controller.py b/functest/opnfv_tests/vnf/router/vnf_controller/vm_controller.py index 56dc1e237..79acc776f 100644 --- a/functest/opnfv_tests/vnf/router/vnf_controller/vm_controller.py +++ b/functest/opnfv_tests/vnf/router/vnf_controller/vm_controller.py @@ -124,11 +124,11 @@ class VmController(object): def command_list_execute(self, ssh, command_list, prompt): res_data_list = [] for command in command_list: - self.logger.debug("Command : " + command) + self.logger.debug("Command : %s", command) (res, res_data) = self.command_execute(ssh, command, prompt) - self.logger.debug("Response : " + res_data) + self.logger.debug("Response : %s", res_data) res_data_list.append(res_data) if not res: return res, res_data_list @@ -140,7 +140,7 @@ class VmController(object): def command_execute(self, ssh, command, prompt): res_data = ssh.send(command, prompt) if res_data is None: - self.logger.info("retry send command : " + command) + self.logger.info("retry send command : %s", command) res_data = ssh.send(command, prompt) if not ssh.error_check(res_data): diff --git a/functest/opnfv_tests/vnf/router/vrouter_base.py b/functest/opnfv_tests/vnf/router/vrouter_base.py index 8818032da..6c4e5ce0d 100644 --- a/functest/opnfv_tests/vnf/router/vrouter_base.py +++ b/functest/opnfv_tests/vnf/router/vrouter_base.py @@ -65,9 +65,9 @@ class VrouterOnBoardingBase(vnf.VnfOnBoarding): test_list = function_test["test_list"] target_vnf_name = function_test["target_vnf_name"] for test_info in test_list: - self.logger.info(test_info["protocol"] + " " + - test_info["test_kind"] + - " test.") + self.logger.info( + "%s %s test.", test_info["protocol"], + test_info["test_kind"]) (result, result_data) = self.function_test_vrouter( target_vnf_name, test_info) test_result_data_list.append(result_data) diff --git a/functest/tests/unit/odl/test_odl.py b/functest/tests/unit/odl/test_odl.py index d50e052c7..bf509cbd6 100644 --- a/functest/tests/unit/odl/test_odl.py +++ b/functest/tests/unit/odl/test_odl.py @@ -362,6 +362,7 @@ class ODLRunTesting(ODLTesting): @mock.patch('os_client_config.make_shade') def _test_run(self, status=testcase.TestCase.EX_OK, exception=None, *args, **kwargs): + # pylint: disable=keyword-arg-before-vararg args[0].return_value.search_services.return_value = [ munch.Munch(id=self._neutron_id)] args[0].return_value.search_endpoints.return_value = [ @@ -393,6 +394,7 @@ class ODLRunTesting(ODLTesting): @mock.patch('os_client_config.make_shade') def _test_multiple_suites(self, suites, status=testcase.TestCase.EX_OK, *args, **kwargs): + # pylint: disable=keyword-arg-before-vararg args[0].return_value.search_endpoints.return_value = [ munch.Munch(url=self._neutron_url)] args[0].return_value.search_services.return_value = [ diff --git a/test-requirements.txt b/test-requirements.txt index 2f570745e..eb5a41328 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -5,7 +5,7 @@ coverage!=4.4,>=4.0 # Apache-2.0 mock>=2.0.0 # BSD nose>=1.3.7 # LGPL flake8<2.6.0,>=2.5.4 # MIT -pylint==1.4.5 # GPLv2 +pylint # GPLv2 sphinx!=1.6.6,!=1.6.7,>=1.6.2 # BSD sphinx-opnfv-theme sphinx-rtd-theme diff --git a/tox.ini b/tox.ini index 64ccb7bdc..8a2bfd7cd 100644 --- a/tox.ini +++ b/tox.ini @@ -75,8 +75,9 @@ modules = functest.utils.functest_utils commands = bash -c "\ - pylint -f parseable --ignore-imports=y --disable=locally-disabled functest | \ - tee pylint.out | sed -ne '/Raw metrics/,//p'" + pylint -f parseable \ + --ignore-imports=y \ + --disable=locally-disabled functest | tee pylint.out" pylint --reports=n --errors-only functest pylint --disable=locally-disabled \ --disable=duplicate-code \ -- cgit 1.2.3-korg