summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChangBo Guo(gcb) <eric.guo@easystack.cn>2014-06-17 15:56:47 +0800
committerChangBo Guo(gcb) <eric.guo@easystack.cn>2014-07-09 14:10:23 +0800
commit1db17aaad9a04cc98fc848b23a76db52a5f62965 (patch)
tree71b4f83400d64dd7bae7cb3fd3db847647c14545
parentd613adc434e93c24d7c3bb34849d2aed1710e0d5 (diff)
downloadpython-glanceclient-1db17aaad9a04cc98fc848b23a76db52a5f62965.tar.gz
Enable F841
F841 detects local variable is assigned to but never used. This commit fixes the violations and enables F841 in gate. Change-Id: Ic4dcac2733dfe334009327ac17aa3952cafaa63a
-rw-r--r--glanceclient/shell.py2
-rw-r--r--glanceclient/v2/shell.py3
-rw-r--r--tests/test_ssl.py53
-rw-r--r--tests/v1/test_images.py5
-rw-r--r--tests/v1/test_legacy_shell.py18
-rw-r--r--tests/v2/test_images.py6
-rw-r--r--tests/v2/test_shell_v2.py1
-rw-r--r--tox.ini2
8 files changed, 42 insertions, 48 deletions
diff --git a/glanceclient/shell.py b/glanceclient/shell.py
index 4bef684..43919b0 100644
--- a/glanceclient/shell.py
+++ b/glanceclient/shell.py
@@ -434,7 +434,7 @@ class OpenStackImagesShell(object):
with open(schema_file_path, 'w') as f:
f.write(json.dumps(schema.raw()))
- except Exception as e:
+ except Exception:
#NOTE(esheffield) do nothing here, we'll get a message later
#if the schema is missing
pass
diff --git a/glanceclient/v2/shell.py b/glanceclient/v2/shell.py
index 4d0e360..7ed4d3c 100644
--- a/glanceclient/v2/shell.py
+++ b/glanceclient/v2/shell.py
@@ -117,7 +117,6 @@ def do_image_list(gc, args):
def do_image_show(gc, args):
"""Describe a specific image."""
image = gc.images.get(args.id)
- ignore = ['self', 'access', 'file', 'schema']
utils.print_image(image, int(args.max_column_width))
@@ -285,7 +284,7 @@ def do_location_add(gc, args):
help='ID of image whose locations are to be removed.')
def do_location_delete(gc, args):
"""Remove locations (and related metadata) from an image."""
- image = gc.images.delete_locations(args.id, set(args.url))
+ gc.images.delete_locations(args.id, set(args.url))
@utils.arg('--url', metavar='<URL>', required=True,
diff --git a/tests/test_ssl.py b/tests/test_ssl.py
index 64ac3e4..f8278a7 100644
--- a/tests/test_ssl.py
+++ b/tests/test_ssl.py
@@ -35,10 +35,10 @@ class TestVerifiedHTTPSConnection(testtools.TestCase):
cert_file = os.path.join(TEST_VAR_DIR, 'certificate.crt')
cacert = os.path.join(TEST_VAR_DIR, 'ca.crt')
try:
- conn = http.VerifiedHTTPSConnection('127.0.0.1', 0,
- key_file=key_file,
- cert_file=cert_file,
- cacert=cacert)
+ http.VerifiedHTTPSConnection('127.0.0.1', 0,
+ key_file=key_file,
+ cert_file=cert_file,
+ cacert=cacert)
except exc.SSLConfigurationError:
self.fail('Failed to init VerifiedHTTPSConnection.')
@@ -49,9 +49,9 @@ class TestVerifiedHTTPSConnection(testtools.TestCase):
cert_file = os.path.join(TEST_VAR_DIR, 'certificate.crt')
cacert = os.path.join(TEST_VAR_DIR, 'ca.crt')
try:
- conn = http.VerifiedHTTPSConnection('127.0.0.1', 0,
- cert_file=cert_file,
- cacert=cacert)
+ http.VerifiedHTTPSConnection('127.0.0.1', 0,
+ cert_file=cert_file,
+ cacert=cacert)
self.fail('Failed to raise assertion.')
except exc.SSLConfigurationError:
pass
@@ -63,9 +63,9 @@ class TestVerifiedHTTPSConnection(testtools.TestCase):
key_file = os.path.join(TEST_VAR_DIR, 'privatekey.key')
cacert = os.path.join(TEST_VAR_DIR, 'ca.crt')
try:
- conn = http.VerifiedHTTPSConnection('127.0.0.1', 0,
- key_file=key_file,
- cacert=cacert)
+ http.VerifiedHTTPSConnection('127.0.0.1', 0,
+ key_file=key_file,
+ cacert=cacert)
except exc.SSLConfigurationError:
pass
except Exception:
@@ -75,13 +75,12 @@ class TestVerifiedHTTPSConnection(testtools.TestCase):
"""
Test VerifiedHTTPSConnection: bad key.
"""
- key_file = os.path.join(TEST_VAR_DIR, 'badkey.key')
cert_file = os.path.join(TEST_VAR_DIR, 'certificate.crt')
cacert = os.path.join(TEST_VAR_DIR, 'ca.crt')
try:
- conn = http.VerifiedHTTPSConnection('127.0.0.1', 0,
- cert_file=cert_file,
- cacert=cacert)
+ http.VerifiedHTTPSConnection('127.0.0.1', 0,
+ cert_file=cert_file,
+ cacert=cacert)
self.fail('Failed to raise assertion.')
except exc.SSLConfigurationError:
pass
@@ -90,13 +89,12 @@ class TestVerifiedHTTPSConnection(testtools.TestCase):
"""
Test VerifiedHTTPSConnection: bad cert.
"""
- key_file = os.path.join(TEST_VAR_DIR, 'privatekey.key')
cert_file = os.path.join(TEST_VAR_DIR, 'badcert.crt')
cacert = os.path.join(TEST_VAR_DIR, 'ca.crt')
try:
- conn = http.VerifiedHTTPSConnection('127.0.0.1', 0,
- cert_file=cert_file,
- cacert=cacert)
+ http.VerifiedHTTPSConnection('127.0.0.1', 0,
+ cert_file=cert_file,
+ cacert=cacert)
self.fail('Failed to raise assertion.')
except exc.SSLConfigurationError:
pass
@@ -105,13 +103,12 @@ class TestVerifiedHTTPSConnection(testtools.TestCase):
"""
Test VerifiedHTTPSConnection: bad CA.
"""
- key_file = os.path.join(TEST_VAR_DIR, 'privatekey.key')
cert_file = os.path.join(TEST_VAR_DIR, 'certificate.crt')
cacert = os.path.join(TEST_VAR_DIR, 'badca.crt')
try:
- conn = http.VerifiedHTTPSConnection('127.0.0.1', 0,
- cert_file=cert_file,
- cacert=cacert)
+ http.VerifiedHTTPSConnection('127.0.0.1', 0,
+ cert_file=cert_file,
+ cacert=cacert)
self.fail('Failed to raise assertion.')
except exc.SSLConfigurationError:
pass
@@ -251,7 +248,7 @@ class TestVerifiedHTTPSConnection(testtools.TestCase):
cert_file = os.path.join(TEST_VAR_DIR, 'certificate.crt')
cacert = os.path.join(TEST_VAR_DIR, 'ca.crt')
try:
- conn = http.VerifiedHTTPSConnection(
+ http.VerifiedHTTPSConnection(
'127.0.0.1', 0,
key_file=key_file,
cert_file=cert_file,
@@ -267,7 +264,7 @@ class TestVerifiedHTTPSConnection(testtools.TestCase):
cert_file = os.path.join(TEST_VAR_DIR, 'certificate.crt')
cacert = os.path.join(TEST_VAR_DIR, 'ca.crt')
try:
- conn = http.VerifiedHTTPSConnection(
+ http.VerifiedHTTPSConnection(
'127.0.0.1', 0,
key_file=key_file,
cert_file=cert_file,
@@ -289,9 +286,9 @@ class TestVerifiedHTTPSConnection(testtools.TestCase):
cert_file = cert_file.encode('ascii', 'strict').decode('utf-8')
cacert = cacert.encode('ascii', 'strict').decode('utf-8')
try:
- conn = http.VerifiedHTTPSConnection('127.0.0.1', 0,
- key_file=key_file,
- cert_file=cert_file,
- cacert=cacert)
+ http.VerifiedHTTPSConnection('127.0.0.1', 0,
+ key_file=key_file,
+ cert_file=cert_file,
+ cacert=cacert)
except exc.SSLConfigurationError:
self.fail('Failed to init VerifiedHTTPSConnection.')
diff --git a/tests/v1/test_images.py b/tests/v1/test_images.py
index 777bbec..b42cd82 100644
--- a/tests/v1/test_images.py
+++ b/tests/v1/test_images.py
@@ -522,12 +522,11 @@ class ImageManagerTest(testtools.TestCase):
def test_get_encoding(self):
image = self.mgr.get('3')
- expect = [('HEAD', '/v1/images/3', {}, None)]
self.assertEqual(u"ni\xf1o", image.name)
def test_get_req_id(self):
params = {'return_req_id': []}
- image = self.mgr.get('4', **params)
+ self.mgr.get('4', **params)
expect_req_id = ['req-1234']
self.assertEqual(expect_req_id, params['return_req_id'])
@@ -564,7 +563,7 @@ class ImageManagerTest(testtools.TestCase):
'do_checksum': False,
'return_req_id': [],
}
- data = ''.join([b for b in self.mgr.data('4', **params)])
+ ''.join([b for b in self.mgr.data('4', **params)])
expect_req_id = ['req-1234']
self.assertEqual(expect_req_id, params['return_req_id'])
diff --git a/tests/v1/test_legacy_shell.py b/tests/v1/test_legacy_shell.py
index f7e1077..e86d6e6 100644
--- a/tests/v1/test_legacy_shell.py
+++ b/tests/v1/test_legacy_shell.py
@@ -330,7 +330,7 @@ class LegacyShellV1Test(testtools.TestCase):
def __init__(self):
self.images = FakeImage1()
- actual = test_shell.do_delete(FakeClient(), FakeImage1())
+ test_shell.do_delete(FakeClient(), FakeImage1())
def test_show(self):
class Image():
@@ -376,7 +376,7 @@ class LegacyShellV1Test(testtools.TestCase):
gc = client.Client('1', 'http://is.invalid')
with mock.patch.object(gc.images, 'list') as mocked_list:
mocked_list.return_value = [Image(), Image()]
- actual = test_shell.do_index(gc, args)
+ test_shell.do_index(gc, args)
def test_index_return_empty(self):
class Image():
@@ -424,7 +424,7 @@ class LegacyShellV1Test(testtools.TestCase):
gc = client.Client('1', 'http://is.invalid')
with mock.patch.object(gc.images, 'list') as mocked_list:
mocked_list.return_value = [Image(), Image()]
- actual = test_shell.do_details(gc, args)
+ test_shell.do_details(gc, args)
def test_do_image_members(self):
class FakeImage1():
@@ -463,7 +463,7 @@ class LegacyShellV1Test(testtools.TestCase):
def list(self, image):
return [ImageMembers(), ImageMembers()]
- actual = test_shell.do_image_members(FakeClient(), FakeImage1())
+ test_shell.do_image_members(FakeClient(), FakeImage1())
def test_do_member_add_error(self):
class FakeClient():
@@ -492,7 +492,7 @@ class LegacyShellV1Test(testtools.TestCase):
def list(self, image):
return [ImageMembers(), ImageMembers()]
- actual = test_shell.do_member_add(FakeClient(), FakeImage1())
+ test_shell.do_member_add(FakeClient(), FakeImage1())
def test_do_member_images_empty_result(self):
class FakeImage1():
@@ -520,7 +520,7 @@ class LegacyShellV1Test(testtools.TestCase):
def list(self, image):
return [ImageMembers(), ImageMembers()]
- actual = test_shell.do_member_add(FakeClient(), ImageMembers())
+ test_shell.do_member_add(FakeClient(), ImageMembers())
def test_do_members_replace_dry_run_true(self):
class Fake():
@@ -531,7 +531,7 @@ class LegacyShellV1Test(testtools.TestCase):
self.member_id = 'test'
gc = client.Client('1', 'http://is.invalid')
- actual = test_shell.do_members_replace(gc, Fake())
+ test_shell.do_members_replace(gc, Fake())
def test_do_members_replace_dry_run_false(self):
class Fake():
@@ -546,7 +546,7 @@ class LegacyShellV1Test(testtools.TestCase):
with mock.patch.object(gc.image_members, 'list') as mocked_list:
mocked_list.return_value = []
with mock.patch.object(gc.image_members, 'create'):
- actual = test_shell.do_members_replace(gc, Fake())
+ test_shell.do_members_replace(gc, Fake())
def test_do_member_images(self):
class FakeClient():
@@ -563,7 +563,7 @@ class LegacyShellV1Test(testtools.TestCase):
def list(self, member):
return [ImageMembers(), ImageMembers()]
- actual = test_shell.do_member_images(FakeClient(), ImageMembers())
+ test_shell.do_member_images(FakeClient(), ImageMembers())
def test_create_pretty_table(self):
class MyPrettyTable(test_shell.PrettyTable):
diff --git a/tests/v2/test_images.py b/tests/v2/test_images.py
index eeabb88..c93e34e 100644
--- a/tests/v2/test_images.py
+++ b/tests/v2/test_images.py
@@ -697,7 +697,7 @@ class TestController(testtools.TestCase):
image_id = 'a2b83adc-888e-11e3-8872-78acc0b951d8'
new_loc = {'url': 'http://spam.com/', 'metadata': {'spam': 'ham'}}
add_patch = {'path': '/locations/-', 'value': new_loc, 'op': 'add'}
- image = self.controller.add_location(image_id, **new_loc)
+ self.controller.add_location(image_id, **new_loc)
self.assertEqual(self.api.calls, [
self._empty_get(image_id),
self._patch_req(image_id, [add_patch]),
@@ -719,7 +719,7 @@ class TestController(testtools.TestCase):
url_set = set(['http://foo.com/', 'http://bar.com/'])
del_patches = [{'path': '/locations/1', 'op': 'remove'},
{'path': '/locations/0', 'op': 'remove'}]
- image = self.controller.delete_locations(image_id, url_set)
+ self.controller.delete_locations(image_id, url_set)
self.assertEqual(self.api.calls, [
self._empty_get(image_id),
self._patch_req(image_id, del_patches)
@@ -746,7 +746,7 @@ class TestController(testtools.TestCase):
'value': []},
{'path': '/locations', 'op': 'replace',
'value': list(loc_map.values())}]
- image = self.controller.update_location(image_id, **new_loc)
+ self.controller.update_location(image_id, **new_loc)
self.assertEqual(self.api.calls, [
self._empty_get(image_id),
self._patch_req(image_id, mod_patch),
diff --git a/tests/v2/test_shell_v2.py b/tests/v2/test_shell_v2.py
index e5d4095..38d2afb 100644
--- a/tests/v2/test_shell_v2.py
+++ b/tests/v2/test_shell_v2.py
@@ -241,7 +241,6 @@ class ShellV2Test(testtools.TestCase):
args = self._make_args({'id': 'pass', 'url': loc_set})
with mock.patch.object(gc.images, 'delete_locations') as mocked_rmloc:
- expect_image = {'id': 'pass', 'locations': []}
test_shell.do_location_delete(self.gc, args)
mocked_rmloc.assert_called_once_with('pass', loc_set)
diff --git a/tox.ini b/tox.ini
index 86cc0bf..5c97677 100644
--- a/tox.ini
+++ b/tox.ini
@@ -32,6 +32,6 @@ downloadcache = ~/cache/pip
# H302 import only modules
# H303 no wildcard import
# H404 multi line docstring should start with a summary
-ignore = F403,F841,F812,F821,H233,H302,H303,H404
+ignore = F403,F812,F821,H233,H302,H303,H404
show-source = True
exclude = .venv,.tox,dist,doc,*egg,build