Fix code to pass pep8 Tox environment.
Command tox -e pep8 is failing making CI to fail: this fixes it. Change-Id: I5b1acfc4ba2e0eb16f50bfd1cdaa8edc361923d1
This commit is contained in:
parent
1dbff8a530
commit
2d6bcaa7e5
@ -47,8 +47,8 @@ class DeviceTaggingTest(base.BaseV2ComputeTest):
|
|||||||
raise cls.skipException('Neutron is required')
|
raise cls.skipException('Neutron is required')
|
||||||
if not CONF.validation.run_validation:
|
if not CONF.validation.run_validation:
|
||||||
raise cls.skipException('Validation must be enabled')
|
raise cls.skipException('Validation must be enabled')
|
||||||
if (not CONF.compute_feature_enabled.config_drive
|
if (not CONF.compute_feature_enabled.config_drive and
|
||||||
and not CONF.compute_feature_enabled.metadata_service):
|
not CONF.compute_feature_enabled.metadata_service):
|
||||||
raise cls.skipException('One of metadata or config drive must be '
|
raise cls.skipException('One of metadata or config drive must be '
|
||||||
'enabled')
|
'enabled')
|
||||||
|
|
||||||
|
@ -132,8 +132,8 @@ class ListImagesTest(base.BaseV1ImageTest):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def skip_checks(cls):
|
def skip_checks(cls):
|
||||||
super(ListImagesTest, cls).skip_checks()
|
super(ListImagesTest, cls).skip_checks()
|
||||||
if (len(CONF.image.container_formats) < 2
|
if (len(CONF.image.container_formats) < 2 or
|
||||||
or len(CONF.image.disk_formats) < 2):
|
len(CONF.image.disk_formats) < 2):
|
||||||
skip_msg = ("%s skipped as multiple container formats "
|
skip_msg = ("%s skipped as multiple container formats "
|
||||||
"or disk formats are not available." % cls.__name__)
|
"or disk formats are not available." % cls.__name__)
|
||||||
raise cls.skipException(skip_msg)
|
raise cls.skipException(skip_msg)
|
||||||
@ -227,8 +227,8 @@ class ListImagesTest(base.BaseV1ImageTest):
|
|||||||
self.assertEqual(image['disk_format'], self.disk_format_alt)
|
self.assertEqual(image['disk_format'], self.disk_format_alt)
|
||||||
result_set = set(map(lambda x: x['id'], images_list))
|
result_set = set(map(lambda x: x['id'], images_list))
|
||||||
self.assertTrue(self.same_disk_format_set <= result_set)
|
self.assertTrue(self.same_disk_format_set <= result_set)
|
||||||
self.assertFalse(self.created_set - self.same_disk_format_set
|
self.assertFalse(self.created_set - self.same_disk_format_set <=
|
||||||
<= result_set)
|
result_set)
|
||||||
|
|
||||||
@decorators.idempotent_id('2143655d-96d9-4bec-9188-8674206b4b3b')
|
@decorators.idempotent_id('2143655d-96d9-4bec-9188-8674206b4b3b')
|
||||||
def test_index_container_format(self):
|
def test_index_container_format(self):
|
||||||
@ -238,8 +238,8 @@ class ListImagesTest(base.BaseV1ImageTest):
|
|||||||
self.assertEqual(image['container_format'], self.container_format)
|
self.assertEqual(image['container_format'], self.container_format)
|
||||||
result_set = set(map(lambda x: x['id'], images_list))
|
result_set = set(map(lambda x: x['id'], images_list))
|
||||||
self.assertTrue(self.same_container_format_set <= result_set)
|
self.assertTrue(self.same_container_format_set <= result_set)
|
||||||
self.assertFalse(self.created_set - self.same_container_format_set
|
self.assertFalse(self.created_set - self.same_container_format_set <=
|
||||||
<= result_set)
|
result_set)
|
||||||
|
|
||||||
@decorators.idempotent_id('feb32ac6-22bb-4a16-afd8-9454bb714b14')
|
@decorators.idempotent_id('feb32ac6-22bb-4a16-afd8-9454bb714b14')
|
||||||
def test_index_max_size(self):
|
def test_index_max_size(self):
|
||||||
|
@ -46,8 +46,8 @@ class VolumeHostsAdminTestsJSON(base.BaseVolumeAdminTest):
|
|||||||
# show host API should fail (return code: 404). The cinder-volume host
|
# show host API should fail (return code: 404). The cinder-volume host
|
||||||
# is presented in format: <host-name>@driver-name.
|
# is presented in format: <host-name>@driver-name.
|
||||||
c_vol_hosts = [host['host_name'] for host in hosts
|
c_vol_hosts = [host['host_name'] for host in hosts
|
||||||
if (host['service'] == 'cinder-volume'
|
if (host['service'] == 'cinder-volume' and
|
||||||
and host['service-state'] == 'enabled')]
|
host['service-state'] == 'enabled')]
|
||||||
self.assertNotEmpty(c_vol_hosts,
|
self.assertNotEmpty(c_vol_hosts,
|
||||||
"No available cinder-volume host is found, "
|
"No available cinder-volume host is found, "
|
||||||
"all hosts that found are: %s" % hosts)
|
"all hosts that found are: %s" % hosts)
|
||||||
|
@ -104,11 +104,11 @@ class BaseService(object):
|
|||||||
self.tenant_filter['tenant_id'] = self.tenant_id
|
self.tenant_filter['tenant_id'] = self.tenant_id
|
||||||
|
|
||||||
def _filter_by_tenant_id(self, item_list):
|
def _filter_by_tenant_id(self, item_list):
|
||||||
if (item_list is None
|
if (item_list is None or
|
||||||
or not item_list
|
not item_list or
|
||||||
or not hasattr(self, 'tenant_id')
|
not hasattr(self, 'tenant_id') or
|
||||||
or self.tenant_id is None
|
self.tenant_id is None or
|
||||||
or 'tenant_id' not in item_list[0]):
|
'tenant_id' not in item_list[0]):
|
||||||
return item_list
|
return item_list
|
||||||
|
|
||||||
return [item for item in item_list
|
return [item for item in item_list
|
||||||
@ -816,8 +816,8 @@ class RoleService(BaseService):
|
|||||||
if not self.is_save_state:
|
if not self.is_save_state:
|
||||||
roles = [role for role in roles if
|
roles = [role for role in roles if
|
||||||
(role['id'] not in
|
(role['id'] not in
|
||||||
self.saved_state_json['roles'].keys()
|
self.saved_state_json['roles'].keys() and
|
||||||
and role['name'] != CONF.identity.admin_role)]
|
role['name'] != CONF.identity.admin_role)]
|
||||||
LOG.debug("List count, %s Roles after reconcile", len(roles))
|
LOG.debug("List count, %s Roles after reconcile", len(roles))
|
||||||
return roles
|
return roles
|
||||||
except Exception:
|
except Exception:
|
||||||
@ -852,13 +852,16 @@ class ProjectService(BaseService):
|
|||||||
def list(self):
|
def list(self):
|
||||||
projects = self.client.list_projects()['projects']
|
projects = self.client.list_projects()['projects']
|
||||||
if not self.is_save_state:
|
if not self.is_save_state:
|
||||||
projects = [project for project in projects if (project['id']
|
project_ids = self.saved_state_json['projects']
|
||||||
not in self.saved_state_json['projects'].keys()
|
projects = [project
|
||||||
and project['name'] != CONF.auth.admin_project_name)]
|
for project in projects
|
||||||
|
if (project['id'] not in project_ids and
|
||||||
|
project['name'] != CONF.auth.admin_project_name)]
|
||||||
|
|
||||||
if self.is_preserve:
|
if self.is_preserve:
|
||||||
projects = [project for project in projects if project['name']
|
projects = [project
|
||||||
not in CONF_PROJECTS]
|
for project in projects
|
||||||
|
if project['name'] not in CONF_PROJECTS]
|
||||||
|
|
||||||
LOG.debug("List count, %s Projects after reconcile", len(projects))
|
LOG.debug("List count, %s Projects after reconcile", len(projects))
|
||||||
return projects
|
return projects
|
||||||
|
@ -228,12 +228,12 @@ def dont_import_local_tempest_into_lib(logical_line, filename):
|
|||||||
if 'tempest/lib/' not in filename:
|
if 'tempest/lib/' not in filename:
|
||||||
return
|
return
|
||||||
|
|
||||||
if not ('from tempest' in logical_line
|
if not ('from tempest' in logical_line or
|
||||||
or 'import tempest' in logical_line):
|
'import tempest' in logical_line):
|
||||||
return
|
return
|
||||||
|
|
||||||
if ('from tempest.lib' in logical_line
|
if ('from tempest.lib' in logical_line or
|
||||||
or 'import tempest.lib' in logical_line):
|
'import tempest.lib' in logical_line):
|
||||||
return
|
return
|
||||||
|
|
||||||
msg = ("T112: tempest.lib should not import local tempest code to avoid "
|
msg = ("T112: tempest.lib should not import local tempest code to avoid "
|
||||||
@ -266,9 +266,9 @@ def dont_use_config_in_tempest_lib(logical_line, filename):
|
|||||||
if 'tempest/lib/' not in filename:
|
if 'tempest/lib/' not in filename:
|
||||||
return
|
return
|
||||||
|
|
||||||
if ('tempest.config' in logical_line
|
if ('tempest.config' in logical_line or
|
||||||
or 'from tempest import config' in logical_line
|
'from tempest import config' in logical_line or
|
||||||
or 'oslo_config' in logical_line):
|
'oslo_config' in logical_line):
|
||||||
msg = ('T114: tempest.lib can not have any dependency on tempest '
|
msg = ('T114: tempest.lib can not have any dependency on tempest '
|
||||||
'config.')
|
'config.')
|
||||||
yield(0, msg)
|
yield(0, msg)
|
||||||
|
@ -43,8 +43,7 @@ class BaseTestCase(testtools.testcase.WithAttributes, testtools.TestCase):
|
|||||||
super(BaseTestCase, self).setUp()
|
super(BaseTestCase, self).setUp()
|
||||||
if not self.setUpClassCalled:
|
if not self.setUpClassCalled:
|
||||||
raise RuntimeError("setUpClass does not calls the super's "
|
raise RuntimeError("setUpClass does not calls the super's "
|
||||||
"setUpClass in the "
|
"setUpClass in {!r}".format(type(self)))
|
||||||
+ self.__class__.__name__)
|
|
||||||
test_timeout = os.environ.get('OS_TEST_TIMEOUT', 0)
|
test_timeout = os.environ.get('OS_TEST_TIMEOUT', 0)
|
||||||
try:
|
try:
|
||||||
test_timeout = int(test_timeout)
|
test_timeout = int(test_timeout)
|
||||||
@ -62,7 +61,7 @@ class BaseTestCase(testtools.testcase.WithAttributes, testtools.TestCase):
|
|||||||
stderr = self.useFixture(fixtures.StringStream('stderr')).stream
|
stderr = self.useFixture(fixtures.StringStream('stderr')).stream
|
||||||
self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr))
|
self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr))
|
||||||
if (os.environ.get('OS_LOG_CAPTURE') != 'False' and
|
if (os.environ.get('OS_LOG_CAPTURE') != 'False' and
|
||||||
os.environ.get('OS_LOG_CAPTURE') != '0'):
|
os.environ.get('OS_LOG_CAPTURE') != '0'):
|
||||||
self.useFixture(fixtures.LoggerFixture(nuke_handlers=False,
|
self.useFixture(fixtures.LoggerFixture(nuke_handlers=False,
|
||||||
format=self.log_format,
|
format=self.log_format,
|
||||||
level=None))
|
level=None))
|
||||||
|
@ -37,8 +37,8 @@ def details_multiple(output_lines, with_label=False):
|
|||||||
items = []
|
items = []
|
||||||
tables_ = tables(output_lines)
|
tables_ = tables(output_lines)
|
||||||
for table_ in tables_:
|
for table_ in tables_:
|
||||||
if ('Property' not in table_['headers']
|
if ('Property' not in table_['headers'] or
|
||||||
or 'Value' not in table_['headers']):
|
'Value' not in table_['headers']):
|
||||||
raise exceptions.InvalidStructure()
|
raise exceptions.InvalidStructure()
|
||||||
item = {}
|
item = {}
|
||||||
for value in table_['values']:
|
for value in table_['values']:
|
||||||
|
@ -103,7 +103,7 @@ class TestChecker(object):
|
|||||||
def _modules_search(self):
|
def _modules_search(self):
|
||||||
"""Recursive search for python modules in base package"""
|
"""Recursive search for python modules in base package"""
|
||||||
modules = []
|
modules = []
|
||||||
for root, dirs, files in os.walk(self.base_path):
|
for root, _, files in os.walk(self.base_path):
|
||||||
if not os.path.exists(os.path.join(root, '__init__.py')):
|
if not os.path.exists(os.path.join(root, '__init__.py')):
|
||||||
continue
|
continue
|
||||||
root_package = self._path_to_package(root)
|
root_package = self._path_to_package(root)
|
||||||
@ -121,10 +121,10 @@ class TestChecker(object):
|
|||||||
idempotent_id = None
|
idempotent_id = None
|
||||||
for decorator in test_node.decorator_list:
|
for decorator in test_node.decorator_list:
|
||||||
if (hasattr(decorator, 'func') and
|
if (hasattr(decorator, 'func') and
|
||||||
hasattr(decorator.func, 'attr') and
|
hasattr(decorator.func, 'attr') and
|
||||||
decorator.func.attr == DECORATOR_NAME and
|
decorator.func.attr == DECORATOR_NAME and
|
||||||
hasattr(decorator.func, 'value') and
|
hasattr(decorator.func, 'value') and
|
||||||
decorator.func.value.id == DECORATOR_MODULE):
|
decorator.func.value.id == DECORATOR_MODULE):
|
||||||
for arg in decorator.args:
|
for arg in decorator.args:
|
||||||
idempotent_id = ast.literal_eval(arg)
|
idempotent_id = ast.literal_eval(arg)
|
||||||
return idempotent_id
|
return idempotent_id
|
||||||
@ -165,8 +165,8 @@ class TestChecker(object):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _is_test_method(node):
|
def _is_test_method(node):
|
||||||
return (node.__class__ is ast.FunctionDef
|
return (node.__class__ is ast.FunctionDef and
|
||||||
and node.name.startswith('test_'))
|
node.name.startswith('test_'))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _next_node(body, node):
|
def _next_node(body, node):
|
||||||
|
@ -338,15 +338,15 @@ class DynamicCredentialProvider(cred_provider.CredentialProvider):
|
|||||||
credentials = self._create_creds(roles=credential_type)
|
credentials = self._create_creds(roles=credential_type)
|
||||||
self._creds[str(credential_type)] = credentials
|
self._creds[str(credential_type)] = credentials
|
||||||
# Maintained until tests are ported
|
# Maintained until tests are ported
|
||||||
LOG.info("Acquired dynamic creds:\n credentials: %s", credentials)
|
LOG.info("Acquired dynamic creds:\n"
|
||||||
if (self.neutron_available and
|
" credentials: %s", credentials)
|
||||||
self.create_networks):
|
if (self.neutron_available and self.create_networks):
|
||||||
network, subnet, router = self._create_network_resources(
|
network, subnet, router = self._create_network_resources(
|
||||||
credentials.tenant_id)
|
credentials.tenant_id)
|
||||||
credentials.set_resources(network=network, subnet=subnet,
|
credentials.set_resources(network=network, subnet=subnet,
|
||||||
router=router)
|
router=router)
|
||||||
LOG.info("Created isolated network resources for : \n"
|
LOG.info("Created isolated network resources for:\n"
|
||||||
+ " credentials: %s", credentials)
|
" credentials: %s", credentials)
|
||||||
return credentials
|
return credentials
|
||||||
|
|
||||||
def get_primary_creds(self):
|
def get_primary_creds(self):
|
||||||
|
@ -662,8 +662,8 @@ class ScenarioTest(tempest.test.BaseTestCase):
|
|||||||
addresses = (server['addresses'][network['name']]
|
addresses = (server['addresses'][network['name']]
|
||||||
if network else [])
|
if network else [])
|
||||||
for address in addresses:
|
for address in addresses:
|
||||||
if (address['version'] == CONF.validation.ip_version_for_ssh
|
if (address['version'] == CONF.validation.ip_version_for_ssh and # noqa
|
||||||
and address['OS-EXT-IPS:type'] == 'fixed'):
|
address['OS-EXT-IPS:type'] == 'fixed'):
|
||||||
return address['addr']
|
return address['addr']
|
||||||
raise exceptions.ServerUnreachable(server_id=server['id'])
|
raise exceptions.ServerUnreachable(server_id=server['id'])
|
||||||
else:
|
else:
|
||||||
@ -792,8 +792,8 @@ class NetworkScenarioTest(ScenarioTest):
|
|||||||
port_map = [(p["id"], fxip["ip_address"])
|
port_map = [(p["id"], fxip["ip_address"])
|
||||||
for p in ports
|
for p in ports
|
||||||
for fxip in p["fixed_ips"]
|
for fxip in p["fixed_ips"]
|
||||||
if netutils.is_valid_ipv4(fxip["ip_address"])
|
if (netutils.is_valid_ipv4(fxip["ip_address"]) and
|
||||||
and p['status'] in p_status]
|
p['status'] in p_status)]
|
||||||
inactive = [p for p in ports if p['status'] != 'ACTIVE']
|
inactive = [p for p in ports if p['status'] != 'ACTIVE']
|
||||||
if inactive:
|
if inactive:
|
||||||
LOG.warning("Instance has ports that are not ACTIVE: %s", inactive)
|
LOG.warning("Instance has ports that are not ACTIVE: %s", inactive)
|
||||||
|
@ -43,8 +43,8 @@ class TestNetworkAdvancedServerOps(manager.NetworkScenarioTest):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def skip_checks(cls):
|
def skip_checks(cls):
|
||||||
super(TestNetworkAdvancedServerOps, cls).skip_checks()
|
super(TestNetworkAdvancedServerOps, cls).skip_checks()
|
||||||
if not (CONF.network.project_networks_reachable
|
if not (CONF.network.project_networks_reachable or
|
||||||
or CONF.network.public_network_id):
|
CONF.network.public_network_id):
|
||||||
msg = ('Either project_networks_reachable must be "true", or '
|
msg = ('Either project_networks_reachable must be "true", or '
|
||||||
'public_network_id must be defined.')
|
'public_network_id must be defined.')
|
||||||
raise cls.skipException(msg)
|
raise cls.skipException(msg)
|
||||||
|
@ -81,8 +81,8 @@ class TestNetworkBasicOps(manager.NetworkScenarioTest):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def skip_checks(cls):
|
def skip_checks(cls):
|
||||||
super(TestNetworkBasicOps, cls).skip_checks()
|
super(TestNetworkBasicOps, cls).skip_checks()
|
||||||
if not (CONF.network.project_networks_reachable
|
if not (CONF.network.project_networks_reachable or
|
||||||
or CONF.network.public_network_id):
|
CONF.network.public_network_id):
|
||||||
msg = ('Either project_networks_reachable must be "true", or '
|
msg = ('Either project_networks_reachable must be "true", or '
|
||||||
'public_network_id must be defined.')
|
'public_network_id must be defined.')
|
||||||
raise cls.skipException(msg)
|
raise cls.skipException(msg)
|
||||||
|
@ -38,11 +38,11 @@ class TestGettingAddress(manager.NetworkScenarioTest):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def skip_checks(cls):
|
def skip_checks(cls):
|
||||||
super(TestGettingAddress, cls).skip_checks()
|
super(TestGettingAddress, cls).skip_checks()
|
||||||
if not (CONF.network_feature_enabled.ipv6
|
if not (CONF.network_feature_enabled.ipv6 and
|
||||||
and CONF.network_feature_enabled.ipv6_subnet_attributes):
|
CONF.network_feature_enabled.ipv6_subnet_attributes):
|
||||||
raise cls.skipException('IPv6 or its attributes not supported')
|
raise cls.skipException('IPv6 or its attributes not supported')
|
||||||
if not (CONF.network.project_networks_reachable
|
if not (CONF.network.project_networks_reachable or
|
||||||
or CONF.network.public_network_id):
|
CONF.network.public_network_id):
|
||||||
msg = ('Either project_networks_reachable must be "true", or '
|
msg = ('Either project_networks_reachable must be "true", or '
|
||||||
'public_network_id must be defined.')
|
'public_network_id must be defined.')
|
||||||
raise cls.skipException(msg)
|
raise cls.skipException(msg)
|
||||||
|
@ -68,9 +68,9 @@ at_exit_set = set()
|
|||||||
def validate_tearDownClass():
|
def validate_tearDownClass():
|
||||||
if at_exit_set:
|
if at_exit_set:
|
||||||
LOG.error(
|
LOG.error(
|
||||||
"tearDownClass does not call the super's "
|
"tearDownClass does not call the super's tearDownClass in "
|
||||||
"tearDownClass in these classes: \n"
|
"these classes:\n"
|
||||||
+ str(at_exit_set))
|
" %s", at_exit_set)
|
||||||
|
|
||||||
|
|
||||||
atexit.register(validate_tearDownClass)
|
atexit.register(validate_tearDownClass)
|
||||||
@ -582,8 +582,8 @@ class BaseTestCase(testtools.testcase.WithAttributes,
|
|||||||
super(BaseTestCase, self).setUp()
|
super(BaseTestCase, self).setUp()
|
||||||
if not self.__setupclass_called:
|
if not self.__setupclass_called:
|
||||||
raise RuntimeError("setUpClass does not calls the super's"
|
raise RuntimeError("setUpClass does not calls the super's"
|
||||||
"setUpClass in the "
|
"setUpClass in the " +
|
||||||
+ self.__class__.__name__)
|
self.__class__.__name__)
|
||||||
at_exit_set.add(self.__class__)
|
at_exit_set.add(self.__class__)
|
||||||
test_timeout = os.environ.get('OS_TEST_TIMEOUT', 0)
|
test_timeout = os.environ.get('OS_TEST_TIMEOUT', 0)
|
||||||
try:
|
try:
|
||||||
@ -602,7 +602,7 @@ class BaseTestCase(testtools.testcase.WithAttributes,
|
|||||||
stderr = self.useFixture(fixtures.StringStream('stderr')).stream
|
stderr = self.useFixture(fixtures.StringStream('stderr')).stream
|
||||||
self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr))
|
self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr))
|
||||||
if (os.environ.get('OS_LOG_CAPTURE') != 'False' and
|
if (os.environ.get('OS_LOG_CAPTURE') != 'False' and
|
||||||
os.environ.get('OS_LOG_CAPTURE') != '0'):
|
os.environ.get('OS_LOG_CAPTURE') != '0'):
|
||||||
self.useFixture(fixtures.LoggerFixture(nuke_handlers=False,
|
self.useFixture(fixtures.LoggerFixture(nuke_handlers=False,
|
||||||
format=self.log_format,
|
format=self.log_format,
|
||||||
level=None))
|
level=None))
|
||||||
|
Loading…
Reference in New Issue
Block a user