Enable E128 ignore E129

After bumping the hacking version to the 0.9.x series ignores were
added for several rules. This commit fixes the violations for a subset
of these rules and re-enables the checks.

Change-Id: Iaff25fc9e2ecfad0c0574b39ddce0c5188d6c31f
This commit is contained in:
Matthew Treinish 2014-06-17 20:25:40 -04:00
parent 96e9e88dc0
commit 1d14c54fd8
18 changed files with 129 additions and 124 deletions

View File

@ -145,7 +145,7 @@ class AggregatesAdminTestJSON(base.BaseV2ComputeAdminTest):
self.assertEqual(200, resp.status)
self.assertIn((aggregate_id, new_aggregate_name, new_az_name),
map(lambda x:
(x['id'], x['name'], x['availability_zone']),
(x['id'], x['name'], x['availability_zone']),
aggregates))
@test.attr(type='gate')

View File

@ -62,9 +62,9 @@ class AuthorizationTestJSON(base.BaseV2ComputeTest):
name = data_utils.rand_name('image')
resp, body = cls.glance_client.create_image(name=name,
container_format='bare',
disk_format='raw',
is_public=False)
container_format='bare',
disk_format='raw',
is_public=False)
image_id = body['id']
image_file = StringIO.StringIO(('*' * 1024))
resp, body = cls.glance_client.update_image(image_id, data=image_file)

View File

@ -135,7 +135,7 @@ class AggregatesAdminV3Test(base.BaseV3ComputeAdminTest):
self.assertEqual(200, resp.status)
self.assertIn((aggregate_id, new_aggregate_name, new_az_name),
map(lambda x:
(x['id'], x['name'], x['availability_zone']),
(x['id'], x['name'], x['availability_zone']),
aggregates))
@test.attr(type='gate')

View File

@ -85,8 +85,8 @@ class AllowedAddressPairTestJSON(base.BaseNetworkTest):
# Update allowed address pair attribute of port
allowed_address_pairs = [{'ip_address': self.ip_address,
'mac_address': self.mac_address}]
resp, body = self.client.update_port(port_id,
allowed_address_pairs=allowed_address_pairs)
resp, body = self.client.update_port(
port_id, allowed_address_pairs=allowed_address_pairs)
self.assertEqual('200', resp['status'])
newport = body['port']
self._confirm_allowed_address_pair(newport, self.ip_address)

View File

@ -290,8 +290,8 @@ class LoadBalancerTestJSON(base.BaseNetworkTest):
health_monitor = body['health_monitor']
# Verification of health_monitor update
resp, body = (self.client.update_health_monitor
(health_monitor['id'],
admin_state_up=False))
(health_monitor['id'],
admin_state_up=False))
self.assertEqual('200', resp['status'])
updated_health_monitor = body['health_monitor']
self.assertFalse(updated_health_monitor['admin_state_up'])
@ -323,10 +323,10 @@ class LoadBalancerTestJSON(base.BaseNetworkTest):
self.addCleanup(self.client.delete_health_monitor,
health_monitor['id'])
resp, body = (self.client.update_health_monitor
(health_monitor['id'],
http_method="POST",
url_path="/home/user",
expected_codes="290"))
(health_monitor['id'],
http_method="POST",
url_path="/home/user",
expected_codes="290"))
self.assertEqual('200', resp['status'])
updated_health_monitor = body['health_monitor']
self.assertEqual("POST", updated_health_monitor['http_method'])
@ -348,7 +348,7 @@ class LoadBalancerTestJSON(base.BaseNetworkTest):
def test_associate_disassociate_health_monitor_with_pool(self):
# Verify that a health monitor can be associated with a pool
resp, body = (self.client.associate_health_monitor_with_pool
(self.health_monitor['id'], self.pool['id']))
(self.health_monitor['id'], self.pool['id']))
self.assertEqual('201', resp['status'])
resp, body = self.client.show_health_monitor(
self.health_monitor['id'])
@ -360,7 +360,7 @@ class LoadBalancerTestJSON(base.BaseNetworkTest):
self.assertIn(health_monitor['id'], pool['health_monitors'])
# Verify that a health monitor can be disassociated from a pool
resp, body = (self.client.disassociate_health_monitor_with_pool
(self.health_monitor['id'], self.pool['id']))
(self.health_monitor['id'], self.pool['id']))
self.assertEqual('204', resp['status'])
resp, body = self.client.show_pool(self.pool['id'])
pool = body['pool']

View File

@ -115,11 +115,11 @@ class RoutersTest(base.BaseRouterTest):
def test_create_router_with_default_snat_value(self):
# Create a router with default snat rule
name = data_utils.rand_name('router')
router = self._create_router(name,
external_network_id=CONF.network.public_network_id)
self._verify_router_gateway(router['id'],
{'network_id': CONF.network.public_network_id,
'enable_snat': True})
router = self._create_router(
name, external_network_id=CONF.network.public_network_id)
self._verify_router_gateway(
router['id'], {'network_id': CONF.network.public_network_id,
'enable_snat': True})
@test.requires_ext(extension='ext-gw-mode', service='network')
@test.attr(type='smoke')
@ -135,10 +135,10 @@ class RoutersTest(base.BaseRouterTest):
name, external_gateway_info=external_gateway_info)
self.assertEqual('201', resp['status'])
self.addCleanup(self.admin_client.delete_router,
create_body['router']['id'])
create_body['router']['id'])
# Verify snat attributes after router creation
self._verify_router_gateway(create_body['router']['id'],
exp_ext_gw_info=external_gateway_info)
exp_ext_gw_info=external_gateway_info)
@test.attr(type='smoke')
def test_add_remove_router_interface_with_subnet_id(self):

View File

@ -249,8 +249,8 @@ class JavelinCheck(unittest.TestCase):
if return_code is 0:
break
self.assertNotEqual(count, 59,
"Server %s is not pingable at %s" % (
server['name'], addr))
"Server %s is not pingable at %s" % (
server['name'], addr))
def check_volumes(self):
"""Check that the volumes are still there and attached."""
@ -401,7 +401,7 @@ def create_servers(servers):
image_id = _get_image_by_name(client, server['image'])['id']
flavor_id = _get_flavor_by_name(client, server['flavor'])['id']
resp, body = client.servers.create_server(server['name'], image_id,
flavor_id)
flavor_id)
server_id = body['id']
client.servers.wait_for_server_status(server_id, 'ACTIVE')
@ -420,7 +420,7 @@ def destroy_servers(servers):
client.servers.delete_server(response['id'])
client.servers.wait_for_server_termination(response['id'],
ignore_error=True)
ignore_error=True)
#######################

View File

@ -209,8 +209,9 @@ class RestClient(object):
pattern = """Unexpected http success status code {0},
The expected status code is {1}"""
if ((not isinstance(expected_code, list) and
(read_code != expected_code)) or (isinstance(expected_code,
list) and (read_code not in expected_code))):
(read_code != expected_code)) or
(isinstance(expected_code, list) and
(read_code not in expected_code))):
details = pattern.format(read_code, expected_code)
raise exceptions.InvalidHttpSuccessCode(details)

View File

@ -74,7 +74,7 @@ def wait_for_server_status(client, server_id, status, ready_wait=True,
if (server_status == 'ERROR') and raise_on_error:
if 'fault' in body:
raise exceptions.BuildErrorException(body['fault'],
server_id=server_id)
server_id=server_id)
else:
raise exceptions.BuildErrorException(server_id=server_id)

View File

@ -223,5 +223,8 @@ class CommandFailed(Exception):
def __str__(self):
return ("Command '%s' returned non-zero exit status %d.\n"
"stdout:\n%s\n"
"stderr:\n%s" % (self.cmd, self.returncode, self.stdout, self.stderr))
"stdout:\n%s\n"
"stderr:\n%s" % (self.cmd,
self.returncode,
self.stdout,
self.stderr))

View File

@ -110,7 +110,7 @@ class NetworkClientJSON(network_client_base.NetworkClientBase):
def add_router_interface_with_subnet_id(self, router_id, subnet_id):
uri = '%s/routers/%s/add_router_interface' % (self.uri_prefix,
router_id)
router_id)
update_body = {"subnet_id": subnet_id}
update_body = json.dumps(update_body)
resp, body = self.put(uri, update_body)
@ -119,7 +119,7 @@ class NetworkClientJSON(network_client_base.NetworkClientBase):
def add_router_interface_with_port_id(self, router_id, port_id):
uri = '%s/routers/%s/add_router_interface' % (self.uri_prefix,
router_id)
router_id)
update_body = {"port_id": port_id}
update_body = json.dumps(update_body)
resp, body = self.put(uri, update_body)
@ -128,7 +128,7 @@ class NetworkClientJSON(network_client_base.NetworkClientBase):
def remove_router_interface_with_subnet_id(self, router_id, subnet_id):
uri = '%s/routers/%s/remove_router_interface' % (self.uri_prefix,
router_id)
router_id)
update_body = {"subnet_id": subnet_id}
update_body = json.dumps(update_body)
resp, body = self.put(uri, update_body)
@ -137,7 +137,7 @@ class NetworkClientJSON(network_client_base.NetworkClientBase):
def remove_router_interface_with_port_id(self, router_id, port_id):
uri = '%s/routers/%s/remove_router_interface' % (self.uri_prefix,
router_id)
router_id)
update_body = {"port_id": port_id}
update_body = json.dumps(update_body)
resp, body = self.put(uri, update_body)

View File

@ -137,7 +137,7 @@ class NetworkClientXML(client_base.NetworkClientBase):
def add_router_interface_with_subnet_id(self, router_id, subnet_id):
uri = '%s/routers/%s/add_router_interface' % (self.uri_prefix,
router_id)
router_id)
subnet = common.Element("subnet_id", subnet_id)
resp, body = self.put(uri, str(common.Document(subnet)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
@ -145,7 +145,7 @@ class NetworkClientXML(client_base.NetworkClientBase):
def add_router_interface_with_port_id(self, router_id, port_id):
uri = '%s/routers/%s/add_router_interface' % (self.uri_prefix,
router_id)
router_id)
port = common.Element("port_id", port_id)
resp, body = self.put(uri, str(common.Document(port)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
@ -153,7 +153,7 @@ class NetworkClientXML(client_base.NetworkClientBase):
def remove_router_interface_with_subnet_id(self, router_id, subnet_id):
uri = '%s/routers/%s/remove_router_interface' % (self.uri_prefix,
router_id)
router_id)
subnet = common.Element("subnet_id", subnet_id)
resp, body = self.put(uri, str(common.Document(subnet)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
@ -161,7 +161,7 @@ class NetworkClientXML(client_base.NetworkClientBase):
def remove_router_interface_with_port_id(self, router_id, port_id):
uri = '%s/routers/%s/remove_router_interface' % (self.uri_prefix,
router_id)
router_id)
port = common.Element("port_id", port_id)
resp, body = self.put(uri, str(common.Document(port)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)

View File

@ -48,7 +48,7 @@ class VolumeAttachDeleteTest(stressaction.StressAction):
# Step 3: attach volume to vm
self.logger.info("attach volume (%s) to vm %s" %
(volume['id'], server_id))
(volume['id'], server_id))
resp, body = self.manager.servers_client.attach_volume(server_id,
volume['id'],
'/dev/vdc')

View File

@ -192,7 +192,7 @@ class VolumeVerifyStress(stressaction.StressAction):
self._create_volume()
servers_client = self.manager.servers_client
self.logger.info("attach volume (%s) to vm %s" %
(self.volume['id'], self.server_id))
(self.volume['id'], self.server_id))
resp, body = servers_client.attach_volume(self.server_id,
self.volume['id'],
self.part_name)

View File

@ -30,9 +30,9 @@ class TestNegativeAutoTest(base.TestCase):
"http-method": "GET",
"url": "flavors/detail",
"json-schema": {"type": "object",
"properties":
{"minRam": {"type": "integer"},
"minDisk": {"type": "integer"}}
"properties":
{"minRam": {"type": "integer"},
"minDisk": {"type": "integer"}}
},
"resources": ["flavor", "volume", "image"]
}

View File

@ -42,17 +42,17 @@ class TestGlanceHTTPClient(base.TestCase):
self.fake_auth.base_url = mock.MagicMock(return_value=self.endpoint)
self.useFixture(mockpatch.PatchObject(httplib.HTTPConnection,
'request',
side_effect=self.fake_http.request(self.endpoint)[1]))
self.useFixture(mockpatch.PatchObject(
httplib.HTTPConnection,
'request',
side_effect=self.fake_http.request(self.endpoint)[1]))
self.client = glance_http.HTTPClient(self.fake_auth, {})
def _set_response_fixture(self, header, status, resp_body):
resp = fake_http.fake_httplib(header, status=status,
body=six.StringIO(resp_body))
self.useFixture(mockpatch.PatchObject(httplib.HTTPConnection,
'getresponse',
return_value=resp))
'getresponse', return_value=resp))
return resp
def test_json_request_without_content_type_header_in_response(self):

View File

@ -187,7 +187,7 @@ def friendly_function_call_str(call_able, *args, **kwargs):
if len(args):
string += ", "
string += ", ".join("=".join(map(str, (key, value)))
for (key, value) in kwargs.items())
for (key, value) in kwargs.items())
return string + ")"
@ -592,83 +592,83 @@ for code in ('InsufficientAddressCapacity', 'InsufficientInstanceCapacity',
for code in (('AccessDenied', 403),
('AccountProblem', 403),
('AmbiguousGrantByEmailAddress', 400),
('BadDigest', 400),
('BucketAlreadyExists', 409),
('BucketAlreadyOwnedByYou', 409),
('BucketNotEmpty', 409),
('CredentialsNotSupported', 400),
('CrossLocationLoggingProhibited', 403),
('EntityTooSmall', 400),
('EntityTooLarge', 400),
('ExpiredToken', 400),
('IllegalVersioningConfigurationException', 400),
('IncompleteBody', 400),
('IncorrectNumberOfFilesInPostRequest', 400),
('InlineDataTooLarge', 400),
('InvalidAccessKeyId', 403),
('AccountProblem', 403),
('AmbiguousGrantByEmailAddress', 400),
('BadDigest', 400),
('BucketAlreadyExists', 409),
('BucketAlreadyOwnedByYou', 409),
('BucketNotEmpty', 409),
('CredentialsNotSupported', 400),
('CrossLocationLoggingProhibited', 403),
('EntityTooSmall', 400),
('EntityTooLarge', 400),
('ExpiredToken', 400),
('IllegalVersioningConfigurationException', 400),
('IncompleteBody', 400),
('IncorrectNumberOfFilesInPostRequest', 400),
('InlineDataTooLarge', 400),
('InvalidAccessKeyId', 403),
'InvalidAddressingHeader',
('InvalidArgument', 400),
('InvalidBucketName', 400),
('InvalidBucketState', 409),
('InvalidDigest', 400),
('InvalidLocationConstraint', 400),
('InvalidPart', 400),
('InvalidPartOrder', 400),
('InvalidPayer', 403),
('InvalidPolicyDocument', 400),
('InvalidRange', 416),
('InvalidRequest', 400),
('InvalidSecurity', 403),
('InvalidSOAPRequest', 400),
('InvalidStorageClass', 400),
('InvalidTargetBucketForLogging', 400),
('InvalidToken', 400),
('InvalidURI', 400),
('KeyTooLong', 400),
('MalformedACLError', 400),
('MalformedPOSTRequest', 400),
('MalformedXML', 400),
('MaxMessageLengthExceeded', 400),
('MaxPostPreDataLengthExceededError', 400),
('MetadataTooLarge', 400),
('MethodNotAllowed', 405),
('MissingAttachment'),
('MissingContentLength', 411),
('MissingRequestBodyError', 400),
('MissingSecurityElement', 400),
('MissingSecurityHeader', 400),
('NoLoggingStatusForKey', 400),
('NoSuchBucket', 404),
('NoSuchKey', 404),
('NoSuchLifecycleConfiguration', 404),
('NoSuchUpload', 404),
('NoSuchVersion', 404),
('NotSignedUp', 403),
('NotSuchBucketPolicy', 404),
('OperationAborted', 409),
('PermanentRedirect', 301),
('PreconditionFailed', 412),
('Redirect', 307),
('RequestIsNotMultiPartContent', 400),
('RequestTimeout', 400),
('RequestTimeTooSkewed', 403),
('RequestTorrentOfBucketError', 400),
('SignatureDoesNotMatch', 403),
('TemporaryRedirect', 307),
('TokenRefreshRequired', 400),
('TooManyBuckets', 400),
('UnexpectedContent', 400),
('UnresolvableGrantByEmailAddress', 400),
('UserKeyMustBeSpecified', 400)):
('InvalidArgument', 400),
('InvalidBucketName', 400),
('InvalidBucketState', 409),
('InvalidDigest', 400),
('InvalidLocationConstraint', 400),
('InvalidPart', 400),
('InvalidPartOrder', 400),
('InvalidPayer', 403),
('InvalidPolicyDocument', 400),
('InvalidRange', 416),
('InvalidRequest', 400),
('InvalidSecurity', 403),
('InvalidSOAPRequest', 400),
('InvalidStorageClass', 400),
('InvalidTargetBucketForLogging', 400),
('InvalidToken', 400),
('InvalidURI', 400),
('KeyTooLong', 400),
('MalformedACLError', 400),
('MalformedPOSTRequest', 400),
('MalformedXML', 400),
('MaxMessageLengthExceeded', 400),
('MaxPostPreDataLengthExceededError', 400),
('MetadataTooLarge', 400),
('MethodNotAllowed', 405),
('MissingAttachment'),
('MissingContentLength', 411),
('MissingRequestBodyError', 400),
('MissingSecurityElement', 400),
('MissingSecurityHeader', 400),
('NoLoggingStatusForKey', 400),
('NoSuchBucket', 404),
('NoSuchKey', 404),
('NoSuchLifecycleConfiguration', 404),
('NoSuchUpload', 404),
('NoSuchVersion', 404),
('NotSignedUp', 403),
('NotSuchBucketPolicy', 404),
('OperationAborted', 409),
('PermanentRedirect', 301),
('PreconditionFailed', 412),
('Redirect', 307),
('RequestIsNotMultiPartContent', 400),
('RequestTimeout', 400),
('RequestTimeTooSkewed', 403),
('RequestTorrentOfBucketError', 400),
('SignatureDoesNotMatch', 403),
('TemporaryRedirect', 307),
('TokenRefreshRequired', 400),
('TooManyBuckets', 400),
('UnexpectedContent', 400),
('UnresolvableGrantByEmailAddress', 400),
('UserKeyMustBeSpecified', 400)):
_add_matcher_class(BotoTestCase.s3_error_code.client,
code, base=ClientError)
for code in (('InternalError', 500),
('NotImplemented', 501),
('ServiceUnavailable', 503),
('SlowDown', 503)):
('NotImplemented', 501),
('ServiceUnavailable', 503),
('SlowDown', 503)):
_add_matcher_class(BotoTestCase.s3_error_code.server,
code, base=ServerError)

View File

@ -110,7 +110,8 @@ import_exceptions = tempest.services
# E125 is a won't fix until https://github.com/jcrocholl/pep8/issues/126 is resolved. For further detail see https://review.openstack.org/#/c/36788/
# H402 skipped because some docstrings aren't sentences
# E123 skipped because it is ignored by default in the default pep8
# Skipped because of new hacking 0.9: H405,H904,E129,E128
ignore = E125,H402,E123,H404,H405,H904,E129,E128
# E129 skipped because it is too limiting when combined with other rules
# Skipped because of new hacking 0.9: H405,H904
ignore = E125,H402,E123,E129,H404,H405,H904
show-source = True
exclude = .git,.venv,.tox,dist,doc,openstack,*egg