Address new hacking enforcement

Hacking has enabled some new checks by default, and the next update to
the new release will introduce failures in our pep8 job due to these.
The main impact is from I122d250cab90964c346e9d53046a97c25054bc00.

This patch addresses those issues now, so when the new hacking release
starts being used it will not cause a disruption.

Change-Id: I0206bda27eed7257ef749cc3e8c41864ad6e18bb
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
This commit is contained in:
Sean McGinnis
2020-10-13 11:14:37 -05:00
parent 1659700aa4
commit f269346a44
5 changed files with 13 additions and 18 deletions

View File

@@ -202,14 +202,14 @@ class ChunkedDriverTestCase(test.TestCase):
def test_get_compressor_zlib(self):
for algo in ['zlib', 'gzip']:
self.assertTrue('zlib' in str(self.driver._get_compressor(algo)))
self.assertIn('zlib', str(self.driver._get_compressor(algo)))
def test_get_compressor_bz(self):
for algo in ['bz2', 'bzip2']:
self.assertTrue('bz' in str(self.driver._get_compressor(algo)))
self.assertIn('bz', str(self.driver._get_compressor(algo)))
def test_get_compressor_zstd(self):
self.assertTrue('zstd' in str(self.driver._get_compressor('zstd')))
self.assertIn('zstd', str(self.driver._get_compressor('zstd')))
def test_get_compressor_invalid(self):
self.assertRaises(ValueError, self.driver._get_compressor, 'winzip')
@@ -406,12 +406,12 @@ class ChunkedDriverTestCase(test.TestCase):
object_meta = {}
self.driver._backup_metadata(self.backup, object_meta)
self.assertTrue('volume_meta' in object_meta.keys())
self.assertIn('volume_meta', object_meta.keys())
# Too much that we mostly don't care about for UT purposes. Just spot
# check a few things
metadata = json.loads(object_meta['volume_meta'])
self.assertTrue('volume-base-metadata' in metadata.keys())
self.assertIn('volume-base-metadata', metadata.keys())
self.assertEqual(self.volume, metadata['volume-base-metadata']['id'])
self.assertEqual(1, metadata['volume-base-metadata']['size'])
self.assertEqual('test_volume',

View File

@@ -282,12 +282,6 @@ class TestCase(testtools.TestCase):
coordination.COORDINATOR.start()
self.addCleanup(coordination.COORDINATOR.stop)
# TODO(smcginnis) Python 3 deprecates assertRaisesRegexp to
# assertRaisesRegex, but Python 2 does not have the new name. This
# can be removed once we stop supporting py2 or the new name is
# added.
self.assertRaisesRegexp = self.assertRaisesRegex
# Ensure we have the default tpool size value and we don't carry
# threads from other test runs.
tpool.killall()

View File

@@ -128,8 +128,8 @@ class TestVolumeAttachDetach(powerstore.TestPowerStoreDriver):
self.fc_driver.adapter.allowed_ports = ["58:cc:f0:98:49:23:07:02"]
wwns = self.fc_driver.adapter._get_fc_targets()
self.assertEqual(1, len(wwns))
self.assertFalse(
utils.fc_wwn_to_string("58:cc:f0:98:49:21:07:02") in wwns
self.assertNotIn(
utils.fc_wwn_to_string("58:cc:f0:98:49:21:07:02"), wwns
)
def test_get_fc_targets_filtered_no_matched_ports(self):

View File

@@ -1628,7 +1628,7 @@ class DS8KProxyTest(test.TestCase):
lun = ds8kproxy.Lun(volume)
pool, lss = self.driver._find_pool_lss_pair_from_spec(lun, set())
# if not specify pool, choose pools set in configuration file.
self.assertTrue(pool in self.configuration.san_clustername.split(','))
self.assertIn(pool, self.configuration.san_clustername.split(','))
self.assertEqual(TEST_LSS_ID_1, lss)
def test_create_volume_only_specify_pool(self):
@@ -3582,7 +3582,7 @@ class DS8KProxyTest(test.TestCase):
self.ctxt, group_snapshot, [snapshot]))
location = ast.literal_eval(
snapshots_model_update[0]['provider_location'])
self.assertTrue(location['vol_hex_id'][:2] not in (20, 21, 22, 23))
self.assertNotIn(location['vol_hex_id'][:2], (20, 21, 22, 23))
self.assertEqual('available', snapshots_model_update[0]['status'])
self.assertEqual(fields.GroupStatus.AVAILABLE, model_update['status'])

View File

@@ -1052,11 +1052,12 @@ class PowerFlexDriver(driver.VolumeDriver):
total_capacity_gb, free_capacity_gb, provisioned_capacity = (
self._compute_pool_stats(raw_pool_stats)
)
LOG.info("Free capacity of Storage Pool %(pool)s: %(free)s, "
"total capacity: %(total)s, "
LOG.info("Free capacity of Storage Pool %(domain)s:%(pool)s: "
"%(free)s, total capacity: %(total)s, "
"provisioned capacity: %(prov)s.",
{
"pool": "%s:%s" % (domain_name, pool_name),
"domain": domain_name,
"pool": pool_name,
"free": free_capacity_gb,
"total": total_capacity_gb,
"prov": provisioned_capacity,