diff --git a/openstack_dashboard/dashboards/admin/aggregates/tests.py b/openstack_dashboard/dashboards/admin/aggregates/tests.py index e0bda5f240..15da9e4eb2 100644 --- a/openstack_dashboard/dashboards/admin/aggregates/tests.py +++ b/openstack_dashboard/dashboards/admin/aggregates/tests.py @@ -325,7 +325,7 @@ class ManageHostsTests(test.BaseAdminViewTests): reverse(constants.AGGREGATES_INDEX_URL)) self.assertEqual(self.mock_aggregate_get.call_count, 2) self.mock_aggregate_get.assert_has_calls( - [mock.call(test.IsHttpRequest(), str(aggregate.id))]*2) + [mock.call(test.IsHttpRequest(), str(aggregate.id))] * 2) self.mock_service_list.assert_called_once_with( test.IsHttpRequest(), binary='nova-compute') self.mock_add_host_to_aggregate.assert_called_once_with( diff --git a/openstack_dashboard/dashboards/admin/instances/tests.py b/openstack_dashboard/dashboards/admin/instances/tests.py index 9412f47aed..89d403938c 100644 --- a/openstack_dashboard/dashboards/admin/instances/tests.py +++ b/openstack_dashboard/dashboards/admin/instances/tests.py @@ -50,7 +50,7 @@ class InstanceViewTest(test.BaseAdminViewTests): self.mock_extension_supported.assert_has_calls([ mock.call('AdminActions', test.IsHttpRequest()), mock.call('AdminActions', test.IsHttpRequest()), - mock.call('Shelve', test.IsHttpRequest())]*4) + mock.call('Shelve', test.IsHttpRequest())] * 4) self.assertEqual(12, self.mock_extension_supported.call_count) self.mock_tenant_list.assert_called_once_with(test.IsHttpRequest()) self.mock_image_list_detailed.assert_called_once_with( @@ -94,7 +94,7 @@ class InstanceViewTest(test.BaseAdminViewTests): self.mock_extension_supported.assert_has_calls([ mock.call('AdminActions', test.IsHttpRequest()), mock.call('AdminActions', test.IsHttpRequest()), - mock.call('Shelve', test.IsHttpRequest())]*4) + mock.call('Shelve', test.IsHttpRequest())] * 4) self.assertEqual(12, self.mock_extension_supported.call_count) self.mock_flavor_list.assert_called_once_with(test.IsHttpRequest()) self.mock_tenant_list.assert_called_once_with(test.IsHttpRequest()) @@ -143,7 +143,7 @@ class InstanceViewTest(test.BaseAdminViewTests): self.mock_extension_supported.assert_has_calls([ mock.call('AdminActions', test.IsHttpRequest()), mock.call('AdminActions', test.IsHttpRequest()), - mock.call('Shelve', test.IsHttpRequest())]*4) + mock.call('Shelve', test.IsHttpRequest())] * 4) self.assertEqual(12, self.mock_extension_supported.call_count) self.mock_tenant_list.assert_called_once_with(test.IsHttpRequest()) self.mock_flavor_get.assert_has_calls( @@ -247,7 +247,7 @@ class InstanceViewTest(test.BaseAdminViewTests): self.mock_extension_supported.assert_has_calls([ mock.call('AdminActions', test.IsHttpRequest()), mock.call('AdminActions', test.IsHttpRequest()), - mock.call('Shelve', test.IsHttpRequest())]*4) + mock.call('Shelve', test.IsHttpRequest())] * 4) self.assertEqual(12, self.mock_extension_supported.call_count) @test.create_mocks({ @@ -280,7 +280,7 @@ class InstanceViewTest(test.BaseAdminViewTests): self.mock_extension_supported.assert_has_calls([ mock.call('AdminActions', test.IsHttpRequest()), mock.call('AdminActions', test.IsHttpRequest()), - mock.call('Shelve', test.IsHttpRequest())]*4) + mock.call('Shelve', test.IsHttpRequest())] * 4) self.assertEqual(12, self.mock_extension_supported.call_count) search_opts = {'marker': None, 'paginate': True, 'all_tenants': True} self.mock_server_list.assert_called_once_with( diff --git a/openstack_dashboard/dashboards/admin/routers/tests.py b/openstack_dashboard/dashboards/admin/routers/tests.py index 6b046ae6be..cef42a7be3 100644 --- a/openstack_dashboard/dashboards/admin/routers/tests.py +++ b/openstack_dashboard/dashboards/admin/routers/tests.py @@ -287,7 +287,7 @@ class RouterTests(RouterMixin, r_test.RouterTestCase, test.BaseAdminViewTests): self.assert_mock_multiple_calls_with_same_arguments( self.mock_is_extension_supported, 2, - mock.call(test.IsHttpRequest(), "router_availability_zone")) + mock.call(test.IsHttpRequest(), "router_availability_zone")) self.mock_tenant_list.assert_called_once_with(test.IsHttpRequest()) diff --git a/openstack_dashboard/dashboards/project/images/tests.py b/openstack_dashboard/dashboards/project/images/tests.py index 08dcfde9dd..afcee9f6c3 100644 --- a/openstack_dashboard/dashboards/project/images/tests.py +++ b/openstack_dashboard/dashboards/project/images/tests.py @@ -307,7 +307,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 a9a85b95c0..fed49e8dcf 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/networks/tests.py b/openstack_dashboard/dashboards/project/networks/tests.py index 97366073a1..049e5d4d07 100644 --- a/openstack_dashboard/dashboards/project/networks/tests.py +++ b/openstack_dashboard/dashboards/project/networks/tests.py @@ -994,7 +994,7 @@ class NetworkTests(test.TestCase, NetworkStubMixin): self._check_net_list() self.mock_is_extension_supported.assert_called_once_with( - test.IsHttpRequest(), 'network_availability_zone') + test.IsHttpRequest(), 'network_availability_zone') self.mock_network_delete.assert_called_once_with( test.IsHttpRequest(), network.id) @@ -1016,7 +1016,7 @@ class NetworkTests(test.TestCase, NetworkStubMixin): self._check_net_list() self.mock_is_extension_supported.assert_called_once_with( - test.IsHttpRequest(), 'network_availability_zone') + test.IsHttpRequest(), 'network_availability_zone') self.mock_network_delete.assert_called_once_with( test.IsHttpRequest(), network.id) @@ -1038,7 +1038,7 @@ class NetworkTests(test.TestCase, NetworkStubMixin): self._check_net_list() self.mock_is_extension_supported.assert_called_once_with( - test.IsHttpRequest(), 'network_availability_zone') + test.IsHttpRequest(), 'network_availability_zone') self.mock_network_delete.assert_called_once_with( test.IsHttpRequest(), network.id) diff --git a/openstack_dashboard/dashboards/project/routers/tests.py b/openstack_dashboard/dashboards/project/routers/tests.py index 3b389d0aab..fd0f231e20 100644 --- a/openstack_dashboard/dashboards/project/routers/tests.py +++ b/openstack_dashboard/dashboards/project/routers/tests.py @@ -533,7 +533,7 @@ class RouterActionTests(test.TestCase): self.mock_network_list.assert_called_once_with( test.IsHttpRequest(), **{'router:external': True}) self.mock_is_extension_supported.assert_called_once_with( - test.IsHttpRequest(), "router_availability_zone") + test.IsHttpRequest(), "router_availability_zone") self.mock_router_create.assert_called_once_with( test.IsHttpRequest(), name=router.name, admin_state_up=False) diff --git a/openstack_dashboard/test/integration_tests/basewebobject.py b/openstack_dashboard/test/integration_tests/basewebobject.py index 3cc13e12e3..aae87e910f 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 7297716740..32e1cd1235 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/tox.ini b/tox.ini index 87c15adbb0..59af27020f 100644 --- a/tox.ini +++ b/tox.ini @@ -155,7 +155,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 # H106 Do not put vim configuration in source files. # H203 Use assertIs(Not)None to check for None.