diff options
author | Akihiro Motoki <amotoki@gmail.com> | 2018-04-11 00:28:25 +0900 |
---|---|---|
committer | Ivan Kolodyazhny <e0ne@e0ne.info> | 2018-04-11 19:37:27 +0300 |
commit | c51a46e8e786fe83067ab14b8ae257193001779d (patch) | |
tree | 14df4d76a9f7882fb740081dc749f25ef050597a | |
parent | 486162d1b9d7cb4e34791a8c2380158c38218ba9 (diff) | |
download | horizon-c51a46e8e786fe83067ab14b8ae257193001779d.tar.gz |
Fix pep8 errors
Recent pep8 upgrade and corresponding pycodestyle update break
horizon pep8 job due to the new rules.
This commit fixes the following new errors:
- E226 missing whitespace around arithmetic operator
- E241 multiple spaces after ','
- E731 do not assign a lambda expression, use a def
The following errors are added to the ignore list
as there are many errors:
- E402 module level import not at top of file
- W503 line break before binary operator
Conflicts:
openstack_dashboard/dashboards/admin/aggregates/tests.py
openstack_dashboard/dashboards/admin/instances/tests.py
openstack_dashboard/dashboards/admin/routers/tests.py
openstack_dashboard/dashboards/project/networks/tests.py
openstack_dashboard/dashboards/project/routers/tests.py
Change-Id: I3478b0684175d2604bbcc1d89cbfca298b97f1e1
(cherry picked from commit f545272f129b8310fa44084cef0e23770c20f9dc)
10 files changed, 58 insertions, 40 deletions
diff --git a/openstack_dashboard/dashboards/admin/floating_ips/tests.py b/openstack_dashboard/dashboards/admin/floating_ips/tests.py index 10c0a3d1a..8bf7aa55a 100644 --- a/openstack_dashboard/dashboards/admin/floating_ips/tests.py +++ b/openstack_dashboard/dashboards/admin/floating_ips/tests.py @@ -36,7 +36,8 @@ class AdminFloatingIpViewTest(test.BaseAdminViewTests): tenants = self.tenants.list() api.neutron.tenant_floating_ip_list(IsA(http.HttpRequest), all_tenants=True).AndReturn(fips) - api.nova.server_list(IsA(http.HttpRequest), search_opts={'all_tenants': True}) \ + api.nova.server_list(IsA(http.HttpRequest), + search_opts={'all_tenants': True}) \ .AndReturn([servers, False]) api.keystone.tenant_list(IsA(http.HttpRequest))\ .AndReturn([tenants, False]) @@ -196,7 +197,8 @@ class AdminFloatingIpViewTest(test.BaseAdminViewTests): tenants = self.tenants.list() api.neutron.tenant_floating_ip_list(IsA(http.HttpRequest), all_tenants=True).AndReturn(fips) - api.nova.server_list(IsA(http.HttpRequest), search_opts={'all_tenants': True}) \ + api.nova.server_list(IsA(http.HttpRequest), + search_opts={'all_tenants': True}) \ .AndReturn([servers, False]) api.keystone.tenant_list(IsA(http.HttpRequest))\ .AndReturn([tenants, False]) @@ -226,7 +228,8 @@ class AdminFloatingIpViewTest(test.BaseAdminViewTests): tenants = self.tenants.list() api.neutron.tenant_floating_ip_list(IsA(http.HttpRequest), all_tenants=True).AndReturn(fips) - api.nova.server_list(IsA(http.HttpRequest), search_opts={'all_tenants': True}) \ + api.nova.server_list(IsA(http.HttpRequest), + search_opts={'all_tenants': True}) \ .AndReturn([servers, False]) api.keystone.tenant_list(IsA(http.HttpRequest))\ .AndReturn([tenants, False]) @@ -254,7 +257,8 @@ class AdminFloatingIpViewTest(test.BaseAdminViewTests): tenants = self.tenants.list() api.neutron.tenant_floating_ip_list(IsA(http.HttpRequest), all_tenants=True).AndReturn(fips) - api.nova.server_list(IsA(http.HttpRequest), search_opts={'all_tenants': True}) \ + api.nova.server_list(IsA(http.HttpRequest), + search_opts={'all_tenants': True}) \ .AndReturn([servers, False]) api.keystone.tenant_list(IsA(http.HttpRequest))\ .AndReturn([tenants, False]) diff --git a/openstack_dashboard/dashboards/identity/projects/tests.py b/openstack_dashboard/dashboards/identity/projects/tests.py index 16dd161bf..63e2eeafe 100644 --- a/openstack_dashboard/dashboards/identity/projects/tests.py +++ b/openstack_dashboard/dashboards/identity/projects/tests.py @@ -1048,7 +1048,8 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests): self._check_role_list(keystone_api_version, role_assignments, groups, proj_users, roles, workflow_data) - quotas.tenant_quota_usages(IsA(http.HttpRequest), tenant_id=project.id) \ + quotas.tenant_quota_usages(IsA(http.HttpRequest), + tenant_id=project.id) \ .AndReturn(quota_usages) nova_updated_quota = {key: updated_quota[key] for key in @@ -1203,7 +1204,8 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests): updated_quota = self._get_quota_info(quota) # handle - quotas.tenant_quota_usages(IsA(http.HttpRequest), tenant_id=project.id) \ + quotas.tenant_quota_usages(IsA(http.HttpRequest), + tenant_id=project.id) \ .AndReturn(quota_usages) api.keystone.get_effective_domain_id( @@ -1335,7 +1337,8 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests): self._check_role_list(keystone_api_version, role_assignments, groups, proj_users, roles, workflow_data) - quotas.tenant_quota_usages(IsA(http.HttpRequest), tenant_id=project.id) \ + quotas.tenant_quota_usages(IsA(http.HttpRequest), + tenant_id=project.id) \ .AndReturn(quota_usages) nova_updated_quota = {key: updated_quota[key] for key in @@ -1448,7 +1451,8 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests): updated_quota = self._get_quota_info(quota) # handle - quotas.tenant_quota_usages(IsA(http.HttpRequest), tenant_id=project.id) \ + quotas.tenant_quota_usages(IsA(http.HttpRequest), + tenant_id=project.id) \ .AndReturn(quota_usages) api.keystone.get_effective_domain_id( diff --git a/openstack_dashboard/dashboards/project/images/tests.py b/openstack_dashboard/dashboards/project/images/tests.py index 6e857215b..09aa388c1 100644 --- a/openstack_dashboard/dashboards/project/images/tests.py +++ b/openstack_dashboard/dashboards/project/images/tests.py @@ -261,7 +261,7 @@ class ImagesAndSnapshotsUtilsTests(BaseImagesTestCase): self.exceptions.glance, [private_images, False, False], [shared_images, False, False], - ] + ] images_cache = {} ret = utils.get_available_images(self.request, self.tenant.id, @@ -309,7 +309,7 @@ class ImagesAndSnapshotsUtilsTests(BaseImagesTestCase): self.exceptions.glance, [shared_images, False, False], [private_images, False, False] - ] + ] images_cache = {} ret = utils.get_available_images(self.request, self.tenant.id, images_cache) diff --git a/openstack_dashboard/dashboards/project/instances/utils.py b/openstack_dashboard/dashboards/project/instances/utils.py index a9a85b95c..fed49e8dc 100644 --- a/openstack_dashboard/dashboards/project/instances/utils.py +++ b/openstack_dashboard/dashboards/project/instances/utils.py @@ -53,7 +53,8 @@ def sort_flavor_list(request, flavors): sort_key = flavor_sort.get('key', 'ram') rev = flavor_sort.get('reverse', False) if not callable(sort_key): - key = lambda flavor: get_key(flavor, sort_key) + def key(flavor): + return get_key(flavor, sort_key) else: key = sort_key flavor_list = [(flavor.id, '%s' % flavor.name) diff --git a/openstack_dashboard/dashboards/project/overview/tests.py b/openstack_dashboard/dashboards/project/overview/tests.py index 3459ae2f4..96d4ce47d 100644 --- a/openstack_dashboard/dashboards/project/overview/tests.py +++ b/openstack_dashboard/dashboards/project/overview/tests.py @@ -50,10 +50,12 @@ class UsageViewTests(test.TestCase): .AndReturn(nova_stu_enabled) if tenant_limits_exception: - api.nova.tenant_absolute_limits(IsA(http.HttpRequest), reserved=True)\ + api.nova.tenant_absolute_limits(IsA(http.HttpRequest), + reserved=True)\ .AndRaise(tenant_limits_exception) else: - api.nova.tenant_absolute_limits(IsA(http.HttpRequest), reserved=True) \ + api.nova.tenant_absolute_limits(IsA(http.HttpRequest), + reserved=True) \ .AndReturn(self.limits['absolute']) if nova_stu_enabled: diff --git a/openstack_dashboard/dashboards/project/routers/tests.py b/openstack_dashboard/dashboards/project/routers/tests.py index 62153c558..b0b84c7cb 100644 --- a/openstack_dashboard/dashboards/project/routers/tests.py +++ b/openstack_dashboard/dashboards/project/routers/tests.py @@ -36,7 +36,8 @@ class RouterMixin(object): }) def _get_detail(self, router, extraroute=True, lookup_l3=False, support_l3_agent=True): - api.neutron.is_extension_supported(IsA(http.HttpRequest), 'extraroute')\ + api.neutron.is_extension_supported(IsA(http.HttpRequest), + 'extraroute')\ .MultipleTimes().AndReturn(extraroute) api.neutron.is_extension_supported(IsA(http.HttpRequest), "router_availability_zone")\ @@ -53,7 +54,8 @@ class RouterMixin(object): self._mock_external_network_get(router) if lookup_l3 and support_l3_agent: agent = self.agents.list()[1] - api.neutron.list_l3_agent_hosting_router(IsA(http.HttpRequest), router.id)\ + api.neutron.list_l3_agent_hosting_router(IsA(http.HttpRequest), + router.id)\ .AndReturn([agent]) self.mox.ReplayAll() @@ -896,7 +898,8 @@ class RouterRouteTests(RouterMixin, test.TestCase): pre_router = self.routers_with_routes.first() post_router = copy.deepcopy(pre_router) route = post_router['routes'].pop() - api.neutron.is_extension_supported(IsA(http.HttpRequest), 'extraroute')\ + api.neutron.is_extension_supported(IsA(http.HttpRequest), + 'extraroute')\ .MultipleTimes().AndReturn(True) api.neutron.router_get(IsA(http.HttpRequest), pre_router.id).AndReturn(pre_router) diff --git a/openstack_dashboard/test/integration_tests/basewebobject.py b/openstack_dashboard/test/integration_tests/basewebobject.py index 3cc13e12e..aae87e910 100644 --- a/openstack_dashboard/test/integration_tests/basewebobject.py +++ b/openstack_dashboard/test/integration_tests/basewebobject.py @@ -153,5 +153,6 @@ class BaseWebObject(unittest.TestCase): pass def wait_till_spinner_disappears(self): - getter = lambda: self.driver.find_element(*self._spinner_locator) + def getter(): + return self.driver.find_element(*self._spinner_locator) self.wait_till_element_disappears(getter) diff --git a/openstack_dashboard/test/test_data/neutron_data.py b/openstack_dashboard/test/test_data/neutron_data.py index 729771674..32e1cd123 100644 --- a/openstack_dashboard/test/test_data/neutron_data.py +++ b/openstack_dashboard/test/test_data/neutron_data.py @@ -781,31 +781,31 @@ def data(TEST): # ids/uuids are captured from a live setup. # This collection holds the test setup. - tdata = {'tenant_id': '19c9123a944644cb9e923497a018d0b7', - 'trunk_id': '920625a3-13de-46b4-b6c9-8b35f29b3cfe', - 'security_group': '3fd8c007-9093-4aa3-b475-a0c178d4e1e4', - 'tag_1': 100, - 'tag_2': 200, - 'net': {'tst_id': '5a340332-cc92-42aa-8980-15f47c0d0f3d', - 'tstalt_id': '0fb41ffd-3933-4da4-8a83-025d328aedf3'}, - 'subnet': {'tst_id': '0b883baf-5a21-4605-ab56-229a24ec585b', + tdata = {'tenant_id': '19c9123a944644cb9e923497a018d0b7', + 'trunk_id': '920625a3-13de-46b4-b6c9-8b35f29b3cfe', + 'security_group': '3fd8c007-9093-4aa3-b475-a0c178d4e1e4', + 'tag_1': 100, + 'tag_2': 200, + 'net': {'tst_id': '5a340332-cc92-42aa-8980-15f47c0d0f3d', + 'tstalt_id': '0fb41ffd-3933-4da4-8a83-025d328aedf3'}, + 'subnet': {'tst_id': '0b883baf-5a21-4605-ab56-229a24ec585b', 'tstalt_id': '0e184cf2-97dc-4738-b4b3-1871faf5d685'}, - 'child1': {'id': '9c151ffb-d7a6-4f15-8eae-d0950999fdfe', - 'ip': '10.10.16.140', - 'mac': 'fa:16:3e:22:63:6f', + 'child1': {'id': '9c151ffb-d7a6-4f15-8eae-d0950999fdfe', + 'ip': '10.10.16.140', + 'mac': 'fa:16:3e:22:63:6f', 'device_id': '279989f7-54bb-41d9-ba42-0d61f12fda61'}, - 'child2': {'id': 'cedb145f-c163-4630-98a3-e1990744bdef', - 'ip': '10.10.17.137', - 'mac': 'fa:16:3e:0d:ca:eb', + 'child2': {'id': 'cedb145f-c163-4630-98a3-e1990744bdef', + 'ip': '10.10.17.137', + 'mac': 'fa:16:3e:0d:ca:eb', 'device_id': '9872faaa-b2b2-eeee-9911-21332eedaa77'}, - 'parent': {'id': '5b27429d-048b-40fa-88f9-8e2c4ff7d28b', - 'ip': '10.10.16.141', - 'mac': 'fa:16:3e:ab:a8:22', + 'parent': {'id': '5b27429d-048b-40fa-88f9-8e2c4ff7d28b', + 'ip': '10.10.16.141', + 'mac': 'fa:16:3e:ab:a8:22', 'device_id': 'af75c8e5-a1cc-4567-8d04-44fcd6922890'}, - 'plain': {'id': 'bc04da56-d7fc-461e-b95d-a2c66e77ad9a', - 'ip': '10.10.16.135', - 'mac': 'fa:16:3e:9c:d5:7f', - 'device_id': '7180cede-bcd8-4334-b19f-f7ef2f331f53'}} + 'plain': {'id': 'bc04da56-d7fc-461e-b95d-a2c66e77ad9a', + 'ip': '10.10.16.135', + 'mac': 'fa:16:3e:9c:d5:7f', + 'device_id': '7180cede-bcd8-4334-b19f-f7ef2f331f53'}} # network tst diff --git a/openstack_dashboard/test/unit/api/test_neutron.py b/openstack_dashboard/test/unit/api/test_neutron.py index 2d712ba4f..619dd7b0e 100644 --- a/openstack_dashboard/test/unit/api/test_neutron.py +++ b/openstack_dashboard/test/unit/api/test_neutron.py @@ -365,7 +365,8 @@ class NeutronApiTests(test.APITestCase): 'prefixes': subnetpool_data['prefixes']} neutronclient = self.stub_neutronclient() - neutronclient.update_subnetpool(subnetpool_id, body={'subnetpool': params})\ + neutronclient.update_subnetpool(subnetpool_id, + body={'subnetpool': params})\ .AndReturn({'subnetpool': subnetpool_data}) self.mox.ReplayAll() @@ -162,7 +162,9 @@ commands = [flake8] filename = *.py,django.wsgi exclude = .venv,.git,.tox,dist,*lib/python*,*egg,build,panel_template,dash_template,local_settings.py,*/local/*,*/test/test_plugins/*,.ropeproject,node_modules,openstack_dashboard/enabled/* -ignore = +# E402 module level import not at top of file +# W503 line break before binary operator +ignore = E402,W503 # Enable the following hacking rules which are disabled by default # H203 Use assertIs(Not)None to check for None # H904 Delay string interpolations at logging calls |