From e71b76cf036687401e4fd5994d60e03babaa6c20 Mon Sep 17 00:00:00 2001 From: Davanum Srinivas Date: Thu, 10 Jul 2014 10:46:33 -0400 Subject: [PATCH] Fix more re-definitions and enable F811/F813 in gate Additional issues found by flake8 by enabling F811 and F813. There was only one F813 list comprehension redefinition. The rest of the changes were F811 redefinition of unused name violations. Change-Id: Iad5406c149ab21d360b7e98899a92082197c8c17 --- nova/network/neutronv2/api.py | 4 ++-- nova/tests/virt/xenapi/client/test_objects.py | 5 ----- nova/tests/virt/xenapi/test_volumeops.py | 2 +- nova/tests/volume/test_cinder.py | 2 -- nova/virt/libvirt/lvm.py | 1 - tox.ini | 4 ++-- 6 files changed, 5 insertions(+), 13 deletions(-) diff --git a/nova/network/neutronv2/api.py b/nova/network/neutronv2/api.py index 78a6a87bc0fb..1b2f25915f6e 100644 --- a/nova/network/neutronv2/api.py +++ b/nova/network/neutronv2/api.py @@ -387,8 +387,8 @@ class API(base_api.NetworkAPI): # and in later runs will only be what was created that time. Thus, # this only affects the attach case, not the original use for this # method. - return network_model.NetworkInfo([port for port in nw_info - if port['id'] in created_port_ids + + return network_model.NetworkInfo([vif for vif in nw_info + if vif['id'] in created_port_ids + touched_port_ids]) def _refresh_neutron_extensions_cache(self, context): diff --git a/nova/tests/virt/xenapi/client/test_objects.py b/nova/tests/virt/xenapi/client/test_objects.py index a4e5d35804d1..31d3df5c63b5 100644 --- a/nova/tests/virt/xenapi/client/test_objects.py +++ b/nova/tests/virt/xenapi/client/test_objects.py @@ -102,11 +102,6 @@ class VBDTestCase(stubs.XenAPITestBaseNoDB): self.session.VBD.plug("vbd_ref", "vm_ref") self.session.call_xenapi.assert_called_once_with("VBD.plug", "vbd_ref") - @mock.patch.object(utils, 'synchronized') - def test_vbd_plug_check_synchronized(self, mock_synchronized): - self.session.VBD.plug("vbd_ref", "vm_ref") - mock_synchronized.assert_called_once_with("xenapi-vbd-vm_ref") - def test_unplug(self): self.session.VBD.unplug("vbd_ref", "vm_ref") self.session.call_xenapi.assert_called_once_with("VBD.unplug", diff --git a/nova/tests/virt/xenapi/test_volumeops.py b/nova/tests/virt/xenapi/test_volumeops.py index 5f541a024ebf..5fca3878d4c6 100644 --- a/nova/tests/virt/xenapi/test_volumeops.py +++ b/nova/tests/virt/xenapi/test_volumeops.py @@ -236,7 +236,7 @@ class AttachVolumeTestCase(VolumeOpsTestBase): False) @mock.patch.object(volumeops.VolumeOps, "_attach_volume") - def test_attach_volume_default_hotplug(self, mock_attach): + def test_attach_volume_default_hotplug_connect_volume(self, mock_attach): self.ops.connect_volume({}) mock_attach.assert_called_once_with({}) diff --git a/nova/tests/volume/test_cinder.py b/nova/tests/volume/test_cinder.py index 868bd25a82af..affa85a7c9dc 100644 --- a/nova/tests/volume/test_cinder.py +++ b/nova/tests/volume/test_cinder.py @@ -13,8 +13,6 @@ # License for the specific language governing permissions and limitations # under the License. -import mock - from cinderclient import exceptions as cinder_exception import mock diff --git a/nova/virt/libvirt/lvm.py b/nova/virt/libvirt/lvm.py index 49943606cf88..0671a5086b57 100644 --- a/nova/virt/libvirt/lvm.py +++ b/nova/virt/libvirt/lvm.py @@ -28,7 +28,6 @@ from nova.openstack.common.gettextutils import _LW from nova.openstack.common import log as logging from nova.openstack.common import processutils from nova.openstack.common import units -from nova import utils from nova.virt.libvirt import utils diff --git a/tox.ini b/tox.ini index 7c4525017cd4..05cd9c35e5b7 100644 --- a/tox.ini +++ b/tox.ini @@ -58,10 +58,10 @@ sitepackages = False # E125 is deliberately excluded. See https://github.com/jcrocholl/pep8/issues/126 # The rest of the ignores are TODOs # New from hacking 0.9: E129, E131, E265, E713, H407, H405, H904 -# Stricter in hacking 0.9: F402, F812 +# Stricter in hacking 0.9: F402 # E251 Skipped due to https://github.com/jcrocholl/pep8/issues/301 -ignore = E121,E122,E123,E124,E125,E129,E126,E127,E128,E131,E251,E265,E711,E712,E713,F811,F402,F812,H305,H307,H405,H803,H904 +ignore = E121,E122,E123,E124,E125,E129,E126,E127,E128,E131,E251,E265,E711,E712,E713,F402,H305,H307,H405,H803,H904 exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,tools [hacking]