From 5f0bc1a6f13e13c7dd214c7169d90847f7857f93 Mon Sep 17 00:00:00 2001 From: John Tran Date: Thu, 20 Sep 2012 17:38:01 +0000 Subject: [PATCH] Pep8 fixes, implement pep8 check on tests subdir Fixes bug #1053515 Change-Id: I2b886528c86e0ad5bdae5abf73890366f084e225 --- tests/compute/test_libvirt.py | 2 +- tests/compute/test_nova_notifier.py | 15 ++++++++++----- tests/image/test_glance.py | 6 ++++-- tests/storage/test_impl_mongodb.py | 2 -- tests/volume/test_notifications.py | 6 ++++-- tox.ini | 2 +- 6 files changed, 20 insertions(+), 13 deletions(-) diff --git a/tests/compute/test_libvirt.py b/tests/compute/test_libvirt.py index e1b64d62..1205c0f9 100644 --- a/tests/compute/test_libvirt.py +++ b/tests/compute/test_libvirt.py @@ -132,7 +132,7 @@ class TestNetPollster(test_base.TestCase): domain.XMLDesc(0).AndReturn(dom_xml) self.mox.ReplayAll() interfaces = self.pollster._get_vnics(conn, self.instance) - self.assertTrue('vnet1' in [x['name'] for x in interfaces]) + self.assertTrue('vnet1' in [x['name'] for x in interfaces]) self.assertTrue('fa:16:3e:71:ec:6d', [x['mac'] for x in interfaces]) self.assertTrue([x['dhcpserver'] for x in interfaces]) diff --git a/tests/compute/test_nova_notifier.py b/tests/compute/test_nova_notifier.py index b8e33925..4686fed3 100644 --- a/tests/compute/test_nova_notifier.py +++ b/tests/compute/test_nova_notifier.py @@ -99,7 +99,8 @@ class TestNovaNotifier(base.TestCase): "ephemeral_gb": "0", "vcpus": 1, "host": "fakehost", - "availability_zone": "1e3ce043029547f1a61c1996d1a531a4", + "availability_zone": + "1e3ce043029547f1a61c1996d1a531a4", "created_at": '2012-05-08 20:23:41', "os_type": "linux", "kernel_id": "kernelid", @@ -113,11 +114,13 @@ class TestNovaNotifier(base.TestCase): self.stubs.Set(db, 'instance_get', self.fake_db_instance_get) self.stubs.Set(db, 'instance_info_cache_delete', self.do_nothing) self.stubs.Set(db, 'instance_destroy', self.do_nothing) - self.stubs.Set(db, 'instance_system_metadata_get', self.fake_db_instance_system_metadata_get) + self.stubs.Set(db, 'instance_system_metadata_get', + self.fake_db_instance_system_metadata_get) self.stubs.Set(db, 'block_device_mapping_get_all_by_instance', lambda context, instance: {}) self.stubs.Set(db, 'instance_update_and_get_original', - lambda context, uuid, kwargs: (self.instance, self.instance)) + lambda context, uuid, kwargs: (self.instance, + self.instance)) self.stubs.Set(publish, 'publish_counter', self.do_nothing) nova_notifier.notify.manager.pollsters = [('test', self.Pollster())] @@ -128,6 +131,8 @@ class TestNovaNotifier(base.TestCase): def test_notifications(self): self.compute.terminate_instance(self.context, instance=self.instance) - self.assertEqual(self.Pollster.counters[0][0], nova_notifier.notify.manager) - self.assertEqual(self.Pollster.counters[0][1].id, self.instance['uuid']) + self.assertEqual(self.Pollster.counters[0][0], + nova_notifier.notify.manager) + self.assertEqual(self.Pollster.counters[0][1].id, + self.instance['uuid']) self.assertEqual(len(self.Pollster.counters), 1) diff --git a/tests/image/test_glance.py b/tests/image/test_glance.py index a977dc6c..005c3bf3 100644 --- a/tests/image/test_glance.py +++ b/tests/image/test_glance.py @@ -90,7 +90,8 @@ class TestImagePollster(base.TestCase): super(TestImagePollster, self).setUp() self.context = context.RequestContext('admin', 'admin', is_admin=True) self.manager = manager.AgentManager() - self.stubs.Set(glance._Base, 'iter_images', self.fake_glance_iter_images) + self.stubs.Set(glance._Base, 'iter_images', + self.fake_glance_iter_images) def test_glance_image_counter(self): counters = list(glance.ImagePollster().get_counters(self.manager, @@ -104,5 +105,6 @@ class TestImagePollster(base.TestCase): self.context)) self.assertEqual(len(counters), 3) for image in IMAGE_LIST: - self.assert_(any(map(lambda counter: counter.volume == image['size'], + self.assert_( + any(map(lambda counter: counter.volume == image['size'], counters))) diff --git a/tests/storage/test_impl_mongodb.py b/tests/storage/test_impl_mongodb.py index 7ce4d133..64c6987b 100644 --- a/tests/storage/test_impl_mongodb.py +++ b/tests/storage/test_impl_mongodb.py @@ -459,11 +459,9 @@ class TestGetEventInterval(MongoDBEngineTestBase): self.early1 = self.start - datetime.timedelta(minutes=20) self.early2 = self.start - datetime.timedelta(minutes=10) - self.middle1 = self.start + datetime.timedelta(minutes=10) self.middle2 = self.end - datetime.timedelta(minutes=10) - self.late1 = self.end + datetime.timedelta(minutes=10) self.late2 = self.end + datetime.timedelta(minutes=20) diff --git a/tests/volume/test_notifications.py b/tests/volume/test_notifications.py index 7d4d0ac4..5c93478c 100644 --- a/tests/volume/test_notifications.py +++ b/tests/volume/test_notifications.py @@ -74,7 +74,8 @@ class TestNotifications(unittest.TestCase): counters = v.process_notification(NOTIFICATION_VOLUME_EXISTS) self.assertEqual(len(counters), 1) c = counters[0] - self.assertEqual(c.volume, NOTIFICATION_VOLUME_EXISTS['payload']['size']) + self.assertEqual(c.volume, + NOTIFICATION_VOLUME_EXISTS['payload']['size']) def test_volume_delete(self): v = notifications.Volume() @@ -88,4 +89,5 @@ class TestNotifications(unittest.TestCase): counters = v.process_notification(NOTIFICATION_VOLUME_EXISTS) self.assertEqual(len(counters), 1) c = counters[0] - self.assertEqual(c.volume, NOTIFICATION_VOLUME_EXISTS['payload']['size']) + self.assertEqual(c.volume, + NOTIFICATION_VOLUME_EXISTS['payload']['size']) diff --git a/tox.ini b/tox.ini index 8999960b..26021830 100644 --- a/tox.ini +++ b/tox.ini @@ -18,7 +18,7 @@ commands = {toxinidir}/run_tests.sh --no-path-adjustment --with-coverage --cover [testenv:pep8] deps = pep8==1.1 -commands = pep8 --repeat --show-source ceilometer setup.py bin/ceilometer-agent-central bin/ceilometer-agent-compute bin/ceilometer-collector bin/ceilometer-api +commands = pep8 --repeat --show-source ceilometer setup.py bin/ceilometer-agent-central bin/ceilometer-agent-compute bin/ceilometer-collector bin/ceilometer-api tests [testenv:py26-essex] deps = -r{toxinidir}/tools/pip-requires_essex