From: Avishay Traeger Date: Tue, 3 Dec 2013 07:44:35 +0000 (+0200) Subject: Update hacking to hacking>=0.8.0,<0.9 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=aa453576ff13c97c63dcb3cd5941675ffdc93360;p=openstack-build%2Fcinder-build.git Update hacking to hacking>=0.8.0,<0.9 Update hacking version to match version specified in requirements repo. Fixed the following issues, which the newer version checks for: print "" -> print("") self.assertEquals -> self.assertEqual self.assertNotEquals -> self.assertNotEqual Change-Id: Ic4b70fd8f565cda28e23fe6b1da0e278f949373c Closes-Bug: #1256738 Closes-Bug: #1256737 Closes-Bug: #1257274 --- diff --git a/bin/cinder-rtstool b/bin/cinder-rtstool index 5781b7ed9..07fe5947d 100755 --- a/bin/cinder-rtstool +++ b/bin/cinder-rtstool @@ -37,7 +37,7 @@ def create(backing_device, name, userid, password, initiator_iqns=None): try: rtsroot = rtslib.root.RTSRoot() except rtslib.utils.RTSLibError: - print _('Ensure that configfs is mounted at /sys/kernel/config.') + print(_('Ensure that configfs is mounted at /sys/kernel/config.')) raise # Look to see if BlockStorageObject already exists @@ -94,8 +94,8 @@ def create(backing_device, name, userid, password, initiator_iqns=None): try: rtslib.NetworkPortal(tpg_new, '0.0.0.0', 3260, mode='any') except rtslib.utils.RTSLibError: - print _('Error creating NetworkPortal: ensure port 3260 ' - 'is not in use by another service.') + print(_('Error creating NetworkPortal: ensure port 3260 ' + 'is not in use by another service.')) raise try: @@ -109,7 +109,7 @@ def add_initiator(target_iqn, initiator_iqn, userid, password): try: rtsroot = rtslib.root.RTSRoot() except rtslib.utils.RTSLibError: - print _('Ensure that configfs is mounted at /sys/kernel/config.') + print(_('Ensure that configfs is mounted at /sys/kernel/config.')) raise # Look for the target @@ -165,15 +165,15 @@ def verify_rtslib(): def usage(): - print "Usage:" - print sys.argv[0], \ - "create [device] [name] [userid] [password]", \ - "" - print sys.argv[0], \ - "add-initiator [target_iqn] [userid] [password] [initiator_iqn]" - print sys.argv[0], "get-targets" - print sys.argv[0], "delete [iqn]" - print sys.argv[0], "verify" + print("Usage:") + print(sys.argv[0] + + " create [device] [name] [userid] [password]" + + " ") + print(sys.argv[0] + + " add-initiator [target_iqn] [userid] [password] [initiator_iqn]") + print(sys.argv[0] + " get-targets") + print(sys.argv[0] + " delete [iqn]") + print(sys.argv[0] + " verify") sys.exit(1) diff --git a/cinder/tests/scheduler/test_chance_weigher.py b/cinder/tests/scheduler/test_chance_weigher.py index 4c6b448f1..9beebdb7b 100644 --- a/cinder/tests/scheduler/test_chance_weigher.py +++ b/cinder/tests/scheduler/test_chance_weigher.py @@ -47,19 +47,19 @@ class ChanceWeigherTestCase(test.TestCase): self.fake_random(reset=True) host_state = {'host': 'host.example.com', 'free_capacity_gb': 99999} weight = weigher._weigh_object(host_state, None) - self.assertEquals(1.0, weight) + self.assertEqual(1.0, weight) weight = weigher._weigh_object(host_state, None) - self.assertEquals(2.0, weight) + self.assertEqual(2.0, weight) weight = weigher._weigh_object(host_state, None) - self.assertEquals(3.0, weight) + self.assertEqual(3.0, weight) def test_host_manager_choosing_chance_weigher(self): # ensure HostManager can load the ChanceWeigher # via the entry points mechanism hm = host_manager.HostManager() weighers = hm._choose_host_weighers('ChanceWeigher') - self.assertEquals(1, len(weighers)) - self.assertEquals(weighers[0], ChanceWeigher) + self.assertEqual(1, len(weighers)) + self.assertEqual(weighers[0], ChanceWeigher) def test_use_of_chance_weigher_via_host_manager(self): # ensure we don't lose any hosts when weighing with @@ -68,4 +68,4 @@ class ChanceWeigherTestCase(test.TestCase): fake_hosts = [host_manager.HostState('fake_host%s' % x) for x in xrange(1, 5)] weighed_hosts = hm.get_weighed_hosts(fake_hosts, {}, 'ChanceWeigher') - self.assertEquals(4, len(weighed_hosts)) + self.assertEqual(4, len(weighed_hosts)) diff --git a/cinder/tests/test_backup_ceph.py b/cinder/tests/test_backup_ceph.py index 55dbe6dde..d0d083233 100644 --- a/cinder/tests/test_backup_ceph.py +++ b/cinder/tests/test_backup_ceph.py @@ -397,9 +397,9 @@ class BackupCephTestCase(test.TestCase): self.service.backup(backup, rbd_io) - self.assertEquals(self.called, ['list', 'popen_init', 'read', - 'popen_init', 'write', - 'stdout_close', 'communicate']) + self.assertEqual(self.called, ['list', 'popen_init', 'read', + 'popen_init', 'write', + 'stdout_close', 'communicate']) # Ensure the files are equal self.assertEqual(checksum.digest(), self.checksum.digest()) @@ -515,7 +515,7 @@ class BackupCephTestCase(test.TestCase): self.stubs.Set(self.service.rbd.RBD, 'remove', remove) self.service.delete(backup) - self.assertEquals(self.called, ['remove']) + self.assertEqual(self.called, ['remove']) def test_try_delete_base_image(self): # don't create volume db entry since it should not be required @@ -538,7 +538,7 @@ class BackupCephTestCase(test.TestCase): self.stubs.Set(self.service.rbd.RBD, 'remove', remove) self.service.delete(backup) - self.assertEquals(self.called, ['remove']) + self.assertEqual(self.called, ['remove']) def test_try_delete_base_image_busy(self): """This should induce retries then raise rbd.ImageBusy.""" @@ -658,8 +658,8 @@ class BackupCephTestCase(test.TestCase): self.stubs.Set(fcntl, 'fcntl', lambda *args, **kwargs: 0) self._setup_mock_popen(self, ['out', 'err']) self.service._piped_execute(['foo'], ['bar']) - self.assertEquals(self.called, ['popen_init', 'popen_init', - 'stdout_close', 'communicate']) + self.assertEqual(self.called, ['popen_init', 'popen_init', + 'stdout_close', 'communicate']) def tearDown(self): self.volume_file.close() diff --git a/cinder/tests/test_context.py b/cinder/tests/test_context.py index 48323c7a9..672559413 100644 --- a/cinder/tests/test_context.py +++ b/cinder/tests/test_context.py @@ -86,4 +86,4 @@ class ContextTestCase(test.TestCase): compute_catalog = [{u'type': u'compute', u'name': u'nova'}] ctxt = context.RequestContext('111', '222', service_catalog=service_catalog) - self.assertEquals(ctxt.service_catalog, compute_catalog) + self.assertEqual(ctxt.service_catalog, compute_catalog) diff --git a/cinder/tests/test_db_api.py b/cinder/tests/test_db_api.py index 5b96d966b..d653e9e72 100644 --- a/cinder/tests/test_db_api.py +++ b/cinder/tests/test_db_api.py @@ -461,7 +461,7 @@ class DBAPIVolumeTestCase(BaseTest): db.volume_create(self.ctxt, {'id': 1, 'metadata': metadata}) db.volume_metadata_delete(self.ctxt, 1, 'c') metadata.pop('c') - self.assertEquals(metadata, db.volume_metadata_get(self.ctxt, 1)) + self.assertEqual(metadata, db.volume_metadata_get(self.ctxt, 1)) class DBAPISnapshotTestCase(BaseTest): diff --git a/cinder/tests/test_image_utils.py b/cinder/tests/test_image_utils.py index def72d4a4..4ff5a5214 100644 --- a/cinder/tests/test_image_utils.py +++ b/cinder/tests/test_image_utils.py @@ -177,21 +177,21 @@ class TestUtils(test.TestCase): inf = image_utils.qemu_img_info(TEST_PATH) - self.assertEquals(inf.image, 'qemu.qcow2') - self.assertEquals(inf.backing_file, 'qemu.qcow2') - self.assertEquals(inf.file_format, 'qcow2') - self.assertEquals(inf.virtual_size, 52428800) - self.assertEquals(inf.cluster_size, 65536) - self.assertEquals(inf.disk_size, 200704) - - self.assertEquals(inf.snapshots[0]['id'], '1') - self.assertEquals(inf.snapshots[0]['tag'], 'snap1') - self.assertEquals(inf.snapshots[0]['vm_size'], '1.7G') - self.assertEquals(inf.snapshots[0]['date'], '2011-10-04') - self.assertEquals(inf.snapshots[0]['vm_clock'], - '19:04:00 32:06:34.974') - - self.assertEquals(str(inf), TEST_STR) + self.assertEqual(inf.image, 'qemu.qcow2') + self.assertEqual(inf.backing_file, 'qemu.qcow2') + self.assertEqual(inf.file_format, 'qcow2') + self.assertEqual(inf.virtual_size, 52428800) + self.assertEqual(inf.cluster_size, 65536) + self.assertEqual(inf.disk_size, 200704) + + self.assertEqual(inf.snapshots[0]['id'], '1') + self.assertEqual(inf.snapshots[0]['tag'], 'snap1') + self.assertEqual(inf.snapshots[0]['vm_size'], '1.7G') + self.assertEqual(inf.snapshots[0]['date'], '2011-10-04') + self.assertEqual(inf.snapshots[0]['vm_clock'], + '19:04:00 32:06:34.974') + + self.assertEqual(str(inf), TEST_STR) def _test_fetch_to_raw(self, has_qemu=True, src_inf=None, dest_inf=None): mox = self._mox diff --git a/cinder/tests/test_nexenta.py b/cinder/tests/test_nexenta.py index efb35336c..53917968d 100644 --- a/cinder/tests/test_nexenta.py +++ b/cinder/tests/test_nexenta.py @@ -749,7 +749,7 @@ class TestNexentaUtils(test.TestCase): ) for value, result in values_to_test: - self.assertEquals(utils.str2size(value), result) + self.assertEqual(utils.str2size(value), result) # Invalid format value self.assertRaises(ValueError, utils.str2size, 'A') @@ -775,4 +775,4 @@ class TestNexentaUtils(test.TestCase): '/rest/nms/')), ) for url, result in urls: - self.assertEquals(utils.parse_nms_url(url), result) + self.assertEqual(utils.parse_nms_url(url), result) diff --git a/cinder/tests/test_storwize_svc.py b/cinder/tests/test_storwize_svc.py index bf48525fe..5ed244d86 100644 --- a/cinder/tests/test_storwize_svc.py +++ b/cinder/tests/test_storwize_svc.py @@ -2263,7 +2263,7 @@ class StorwizeSVCDriverTestCase(test.TestCase): volume = self._generate_vol_info(None, None) volume['volume_type_id'] = None self.driver.create_volume(volume) - self.assertNotEquals(cap['extent_size'], self.driver._extent_size) + self.assertNotEqual(cap['extent_size'], self.driver._extent_size) self.driver.migrate_volume(ctxt, volume, host) self.driver.delete_volume(volume) diff --git a/cinder/tests/test_utils.py b/cinder/tests/test_utils.py index cde2a96a5..fb0a52878 100644 --- a/cinder/tests/test_utils.py +++ b/cinder/tests/test_utils.py @@ -77,9 +77,9 @@ exit 1 fp = open(tmpfilename2, 'r+') runs = fp.read() fp.close() - self.assertNotEquals(runs.strip(), 'failure', 'stdin did not ' - 'always get passed ' - 'correctly') + self.assertNotEqual(runs.strip(), 'failure', 'stdin did not ' + 'always get passed ' + 'correctly') runs = int(runs.strip()) self.assertEqual(runs, 10, 'Ran %d times instead of 10.' % (runs,)) finally: diff --git a/test-requirements.txt b/test-requirements.txt index 35f6c8298..e7ecbaacb 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,5 +1,5 @@ # Install bounded pep8/pyflakes first, then let flake8 install -hacking>=0.5.6,<0.8 +hacking>=0.8.0,<0.9 coverage>=3.6 discover fixtures>=0.3.14