From b236c24a1a671ca278b35f98d52267b7788057c7 Mon Sep 17 00:00:00 2001 From: junboli Date: Tue, 18 Jul 2017 18:12:37 +0800 Subject: [PATCH] Enable some off-by-default checks Some of the available checks are disabled by default, like: [H106] Don't put vim configuration in source files [H203] Use assertIs(Not)None to check for None [H904] Use ',' instead of '%', String interpolation should be delayed to be handled by the logging code, rather than being done at the point of the logging call. Change-Id: Ie985fcf78997a86d41e40eacbb4a5ace8592a348 --- manila_tempest_tests/common/remote_client.py | 2 +- manila_tempest_tests/tests/api/base.py | 4 ++-- manila_tempest_tests/tests/api/test_security_services.py | 2 +- .../tests/api/test_security_services_mapping_negative.py | 2 +- .../tests/api/test_security_services_negative.py | 2 +- manila_tempest_tests/tests/scenario/manager_share.py | 2 +- manila_tempest_tests/tests/scenario/test_share_basic_ops.py | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manila_tempest_tests/common/remote_client.py b/manila_tempest_tests/common/remote_client.py index 29f1b498..45f85d85 100644 --- a/manila_tempest_tests/common/remote_client.py +++ b/manila_tempest_tests/common/remote_client.py @@ -80,7 +80,7 @@ class RemoteClient(object): # Shell options below add more clearness on failures, # path is extended for some non-cirros guest oses (centos7) cmd = CONF.validation.ssh_shell_prologue + " " + cmd - LOG.debug("Remote command: %s" % cmd) + LOG.debug("Remote command: %s", cmd) return self.ssh_client.exec_command(cmd) @debug_ssh diff --git a/manila_tempest_tests/tests/api/base.py b/manila_tempest_tests/tests/api/base.py index 65f1b305..d190b63e 100644 --- a/manila_tempest_tests/tests/api/base.py +++ b/manila_tempest_tests/tests/api/base.py @@ -91,7 +91,7 @@ class handle_cleanup_exceptions(object): return False # Do not suppress error if any if exc_traceback: LOG.error("Suppressed cleanup error in Manila: " - "\n%s" % traceback.format_exc()) + "\n%s", traceback.format_exc()) return True # Suppress error if any @@ -925,7 +925,7 @@ class BaseSharesTest(test.BaseTestCase): client.wait_for_resource_deletion(replica_id=res_id) else: LOG.warning("Provided unsupported resource type for " - "cleanup '%s'. Skipping." % res["type"]) + "cleanup '%s'. Skipping.", res["type"]) res["deleted"] = True @classmethod diff --git a/manila_tempest_tests/tests/api/test_security_services.py b/manila_tempest_tests/tests/api/test_security_services.py index 2e287039..fd884f2b 100644 --- a/manila_tempest_tests/tests/api/test_security_services.py +++ b/manila_tempest_tests/tests/api/test_security_services.py @@ -183,7 +183,7 @@ class SecurityServicesTest(base.BaseSharesTest, LOG.warning("Caught exception. It is expected in case backend " "fails having security-service with improper data " "that leads to share-server creation error. " - "%s" % six.text_type(e)) + "%s", six.text_type(e)) update_data = { "name": "name", diff --git a/manila_tempest_tests/tests/api/test_security_services_mapping_negative.py b/manila_tempest_tests/tests/api/test_security_services_mapping_negative.py index d60b4583..c63e7cef 100644 --- a/manila_tempest_tests/tests/api/test_security_services_mapping_negative.py +++ b/manila_tempest_tests/tests/api/test_security_services_mapping_negative.py @@ -115,7 +115,7 @@ class SecServicesMappingNegativeTest(base.BaseSharesTest): LOG.warning("Caught exception. It is expected in case backend " "fails having security-service with improper data " "that leads to share-server creation error. " - "%s" % six.text_type(e)) + "%s", six.text_type(e)) self.assertRaises(lib_exc.Forbidden, self.cl.remove_sec_service_from_share_network, diff --git a/manila_tempest_tests/tests/api/test_security_services_negative.py b/manila_tempest_tests/tests/api/test_security_services_negative.py index eb871a66..cfa97bfb 100644 --- a/manila_tempest_tests/tests/api/test_security_services_negative.py +++ b/manila_tempest_tests/tests/api/test_security_services_negative.py @@ -101,7 +101,7 @@ class SecurityServicesNegativeTest(base.BaseSharesTest): LOG.warning("Caught exception. It is expected in case backend " "fails having security-service with improper data " "that leads to share-server creation error. " - "%s" % six.text_type(e)) + "%s", six.text_type(e)) self.assertRaises(lib_exc.Forbidden, self.shares_client.update_security_service, diff --git a/manila_tempest_tests/tests/scenario/manager_share.py b/manila_tempest_tests/tests/scenario/manager_share.py index 6c25785b..1c671828 100644 --- a/manila_tempest_tests/tests/scenario/manager_share.py +++ b/manila_tempest_tests/tests/scenario/manager_share.py @@ -228,7 +228,7 @@ class ShareScenarioTest(manager.NetworkScenarioTest): try: linux_client.validate_authentication() except Exception: - LOG.exception('Initializing SSH connection to %s failed' % ip) + LOG.exception('Initializing SSH connection to %s failed', ip) self._log_console_output() raise diff --git a/manila_tempest_tests/tests/scenario/test_share_basic_ops.py b/manila_tempest_tests/tests/scenario/test_share_basic_ops.py index ea79ef22..7dba83b4 100644 --- a/manila_tempest_tests/tests/scenario/test_share_basic_ops.py +++ b/manila_tempest_tests/tests/scenario/test_share_basic_ops.py @@ -189,7 +189,7 @@ class ShareBasicOpsBase(manager.ShareScenarioTest): first_address = net_addresses.values()[0][0] ip = first_address['addr'] except Exception: - LOG.debug("Instance: %s" % instance) + LOG.debug("Instance: %s", instance) # In case on an error ip will be still none LOG.exception("Instance does not have a valid IP address." "Falling back to default")