Fix pylint errors 'unused variable'

partially blueprint reduce-pylint-warnings
Change-Id: Iaf0b4e919474db513fe18110f8bf9404df2fb5dd
This commit is contained in:
Nikolay Starodubtsev 2015-09-03 14:28:11 +03:00 committed by Victor Ryzhenkin
parent b1fc727e73
commit a1b34c611e
13 changed files with 45 additions and 47 deletions

View File

@ -93,7 +93,7 @@ class Controller(object):
return None
def list(self, req):
user, passwd, keystone = self._check_auth(req)
user, _, keystone = self._check_auth(req)
# Once we get here we were authorized by keystone
token = keystone.auth_token
@ -144,7 +144,7 @@ class Controller(object):
# Now as we have all parameters we can try to auth user in actual
# tenant
user, passwd, keystone = self._check_auth(req, tenant)
user, _, keystone = self._check_auth(req, tenant)
# Once we get here we were authorized by keystone
token = keystone.auth_token
m_cli = muranoclient(token)
@ -198,7 +198,7 @@ class Controller(object):
service_id = service.service_id
environment_id = service.environment_id
tenant = service.tenant
user, passwd, keystone = self._check_auth(req, tenant)
_, _, keystone = self._check_auth(req, tenant)
# Once we get here we were authorized by keystone
token = keystone.auth_token
m_cli = muranoclient(token)
@ -227,7 +227,7 @@ class Controller(object):
service_id = db_service.service_id
environment_id = db_service.environment_id
tenant = db_service.tenant
user, passwd, keystone = self._check_auth(req, tenant)
_, _, keystone = self._check_auth(req, tenant)
# Once we get here we were authorized by keystone
token = keystone.auth_token
m_cli = muranoclient(token)

View File

@ -200,7 +200,7 @@ def build_entity_map(value):
if isinstance(value, types.DictionaryType):
if '?' in value and 'id' in value['?']:
id_map[value['?']['id']] = value
for k, v in value.iteritems():
for v in value.itervalues():
build_entity_map_recursive(v, id_map)
if isinstance(value, types.ListType):
for item in value:

View File

@ -58,7 +58,7 @@ class MuranoPlException(Exception):
result = MuranoPlException(
names, str(exception), stacktrace)
exc_type, exc_value, exc_traceback = sys.exc_info()
_, _, exc_traceback = sys.exc_info()
result.original_exception = exception
result.original_traceback = exc_traceback
return result

View File

@ -180,7 +180,7 @@ class RepeatMacro(expressions.DslExpression):
def execute(self, context):
count = helpers.evaluate(self._count, context)
for t in range(0, count):
for _ in range(0, count):
try:
self._code.execute(context)
except exceptions.BreakException:
@ -214,7 +214,7 @@ class SwitchMacro(expressions.DslExpression):
raise exceptions.DslSyntaxError(
'Switch value must be of dictionary type')
self._switch = Switch
for key, value in self._switch.iteritems():
for key in self._switch.iterkeys():
if not isinstance(key, (yaql_expression.YaqlExpression,
types.BooleanType)):
raise exceptions.DslSyntaxError(

View File

@ -275,7 +275,7 @@ class MuranoClass(dsl_types.MuranoClass):
while i < len(versions_list):
package1, requirement1 = versions_list[i]
dst_package = None
for j, (package2, requirement2) in enumerate(versions_list):
for j, (package2, _) in enumerate(versions_list):
if i == j:
continue
if package2.version in requirement1 and (

View File

@ -172,7 +172,7 @@ class HotPackage(package_base.PackageBase):
@staticmethod
def _translate_outputs(hot):
result = {}
for key, value in (hot.get('outputs') or {}).items():
for key in (hot.get('outputs') or {}).keys():
result[key] = {
"Contract": YAQL("$.string()"),
"Usage": "Out"
@ -259,7 +259,7 @@ class HotPackage(package_base.PackageBase):
hot_env = YAQL("$.hotEnvironment")
copy_outputs = []
for key, value in (hot.get('outputs') or {}).items():
for key in (hot.get('outputs') or {}).keys():
copy_outputs.append({YAQL('$.' + key): YAQL('$outputs.' + key)})
deploy = [

View File

@ -111,7 +111,7 @@ class Package(object):
def _zip_dir(path, zip_file):
for root, dirs, files in os.walk(path):
for root, _, files in os.walk(path):
for f in files:
abs_path = os.path.join(root, f)
relative_path = os.path.relpath(abs_path, path)

View File

@ -106,8 +106,7 @@ class MuranoClient(rest_client.RestClient):
def deploy_session(self, environment_id, session_id):
post_body = None
url = 'v1/environments/{0}/sessions/{1}/deploy'
resp, body = self.post(url.format(environment_id, session_id),
post_body)
resp, _ = self.post(url.format(environment_id, session_id), post_body)
return resp
@ -283,13 +282,13 @@ class MuranoClient(rest_client.RestClient):
def delete_app_in_env_template(self, env_template_name):
"""Delete an application in an environment template."""
resp, body = self.delete('v1/templates/{0}/services/{1}'.
format(env_template_name, 'ID'))
resp, _ = self.delete('v1/templates/{0}/services/{1}'.
format(env_template_name, 'ID'))
return resp
def delete_env_template(self, env_template_id):
"""Check the deletion of an environment template."""
resp, body = self.delete('v1/templates/{0}'.format(env_template_id))
resp, _ = self.delete('v1/templates/{0}'.format(env_template_id))
return resp
def get_env_template(self, env_template_id):

View File

@ -153,7 +153,7 @@ class TestEnvTemplate(base.TestCase):
@attr(type='negative')
def test_double_delete_env_template(self):
"""Check the deletion of an wrong environment template request."""
resp, env_template = self.client.create_env_template('test_env_temp')
_, env_template = self.client.create_env_template('test_env_temp')
self.client.delete_env_template(env_template['id'])
@ -165,7 +165,7 @@ class TestEnvTemplate(base.TestCase):
@attr(type='negative')
def test_get_deleted_env_template(self):
"""Check the deletion of an wrong environment template request."""
resp, env_template = self.client.create_env_template('test_env_temp')
_, env_template = self.client.create_env_template('test_env_temp')
self.client.delete_env_template(env_template['id'])

View File

@ -80,7 +80,7 @@ class TestCaseShell(testtools.TestCase):
return (stdout, stderr)
def test_help(self):
stdout, stderr = self.shell('--help')
stdout, _ = self.shell('--help')
usage = """usage: murano-test-runner [-h] [-v] [--config-file CONFIG_FILE]
[--os-auth-url OS_AUTH_URL]
[--os-username OS_USERNAME]
@ -96,13 +96,12 @@ class TestCaseShell(testtools.TestCase):
importutils.import_module('keystonemiddleware.auth_token')
self.override_config('admin_user', 'new_value', 'keystone_authtoken')
stdout, stderr = self.shell(
'-p io.murano.test.MyTest1 io.murano.test.MyTest2')
self.shell('-p io.murano.test.MyTest1 io.murano.test.MyTest2')
mock_client.assert_has_calls([mock.call(**self.auth_params)])
def test_package_all_tests(self):
stdout, stderr = self.shell('-p io.murano.test.MyTest1')
_, stderr = self.shell('-p io.murano.test.MyTest1')
# NOTE(efedorova): May be, there is a problem with test-runner, since
# all logs are passed to stderr
self.assertIn('io.murano.test.MyTest1.testSimple1.....OK', stderr)
@ -112,7 +111,7 @@ class TestCaseShell(testtools.TestCase):
self.assertNotIn('thisIsNotAtestMethod', stderr)
def test_package_by_class(self):
stdout, stderr = self.shell(
_, stderr = self.shell(
'-p io.murano.test.MyTest1 io.murano.test.MyTest2')
self.assertNotIn('io.murano.test.MyTest1.testSimple1.....OK', stderr)
@ -121,7 +120,7 @@ class TestCaseShell(testtools.TestCase):
self.assertIn('io.murano.test.MyTest2.testSimple2.....OK', stderr)
def test_package_by_test_name(self):
stdout, stderr = self.shell(
_, stderr = self.shell(
'-p io.murano.test.MyTest1 testSimple1')
self.assertIn('io.murano.test.MyTest1.testSimple1.....OK', stderr)
@ -130,7 +129,7 @@ class TestCaseShell(testtools.TestCase):
self.assertNotIn('io.murano.test.MyTest2.testSimple2.....OK', stderr)
def test_package_by_test_and_class_name(self):
stdout, stderr = self.shell(
_, stderr = self.shell(
'-p io.murano.test.MyTest1 io.murano.test.MyTest2.testSimple1')
self.assertNotIn('io.murano.test.MyTest1.testSimple1.....OK', stderr)
@ -139,17 +138,17 @@ class TestCaseShell(testtools.TestCase):
self.assertNotIn('io.murano.test.MyTest2.testSimple2.....OK', stderr)
def test_service_methods(self):
stdout, stderr = self.shell(
_, stderr = self.shell(
'-p io.murano.test.MyTest1 io.murano.test.MyTest1.testSimple1')
self.assertIn('Executing: io.murano.test.MyTest1.setUp', stderr)
self.assertIn('Executing: io.murano.test.MyTest1.tearDown', stderr)
def test_package_is_not_provided(self):
stdout, stderr = self.shell(exitcode=1)
_, stderr = self.shell(exitcode=1)
self.assertEqual(stderr, 'ERROR: Package name is required parameter.')
def test_wrong_parent(self):
stdout, stderr = self.shell(
_, stderr = self.shell(
'-p io.murano.test.MyTest1 io.murano.test.MyTest3', exitcode=1)
self.assertIn('Class io.murano.test.MyTest3 is not inherited from'
' io.murano.test.TestFixture. Skipping it.', stderr)

View File

@ -54,7 +54,7 @@ class TestCatalogApi(test_base.ControllerTest, test_base.MuranoApiTestCase):
self._set_policy_rules(
{'get_package': ''}
)
for i in range(7):
for dummy in range(7):
self.expect_policy_check('get_package')
pkg = self._add_pkg('test_tenant', type='Library')
@ -106,7 +106,7 @@ class TestCatalogApi(test_base.ControllerTest, test_base.MuranoApiTestCase):
self._set_policy_rules(
{'get_package': ''}
)
for i in range(7):
for dummy in range(7):
self.expect_policy_check('get_package')
pkg = self._add_pkg('test_tenant', type='Library')
@ -156,7 +156,7 @@ class TestCatalogApi(test_base.ControllerTest, test_base.MuranoApiTestCase):
self._set_policy_rules(
{'get_package': ''}
)
for i in range(9):
for dummy in range(9):
self.expect_policy_check('get_package')
result = self.controller.search(self._get('/v1/catalog/packages/'))
@ -238,7 +238,7 @@ class TestCatalogApi(test_base.ControllerTest, test_base.MuranoApiTestCase):
self._set_policy_rules(
{'get_package': '@'}
)
package_from_dir, package = self._test_package()
_, package = self._test_package()
saved_package = db_catalog_api.package_upload(package, '')
@ -261,7 +261,7 @@ class TestCatalogApi(test_base.ControllerTest, test_base.MuranoApiTestCase):
self._set_policy_rules(
{'download_package': '@'}
)
package_from_dir, package = self._test_package()
_, package = self._test_package()
saved_package = db_catalog_api.package_upload(package, '')
@ -278,7 +278,7 @@ class TestCatalogApi(test_base.ControllerTest, test_base.MuranoApiTestCase):
def test_download_package_negative(self):
package_from_dir, package = self._test_package()
_, package = self._test_package()
saved_package = db_catalog_api.package_upload(package, '')
@ -295,7 +295,7 @@ class TestCatalogApi(test_base.ControllerTest, test_base.MuranoApiTestCase):
self._set_policy_rules(
{'get_package': '@'}
)
package_from_dir, package = self._test_package()
_, package = self._test_package()
saved_package = db_catalog_api.package_upload(package, '')
@ -311,7 +311,7 @@ class TestCatalogApi(test_base.ControllerTest, test_base.MuranoApiTestCase):
self.assertEqual(200, result.status_code)
def test_get_ui_definition_negative(self):
package_from_dir, package = self._test_package()
_, package = self._test_package()
saved_package = db_catalog_api.package_upload(package, '')
@ -328,7 +328,7 @@ class TestCatalogApi(test_base.ControllerTest, test_base.MuranoApiTestCase):
self._set_policy_rules(
{'get_package': '@'}
)
package_from_dir, package = self._test_package()
_, package = self._test_package()
saved_package = db_catalog_api.package_upload(package, '')
@ -345,7 +345,7 @@ class TestCatalogApi(test_base.ControllerTest, test_base.MuranoApiTestCase):
self.assertEqual(package['logo'], result.body)
def test_get_logo_negative(self):
package_from_dir, package = self._test_package()
_, package = self._test_package()
saved_package = db_catalog_api.package_upload(package, '')
@ -375,7 +375,7 @@ class TestCatalogApi(test_base.ControllerTest, test_base.MuranoApiTestCase):
file_obj_str = cStringIO.StringIO("This is some dummy data")
file_obj = mock.MagicMock(cgi.FieldStorage)
file_obj.file = file_obj_str
package_from_dir, package_metadata = self._test_package()
package_from_dir, _ = self._test_package()
body = '''\

View File

@ -64,7 +64,7 @@ class CatalogDBTestCase(base.MuranoWithDBTestCase):
def test_order_by(self):
pkgs = []
for i in range(10):
for dummy in range(10):
package = api.package_upload(self._stub_package(
name=str(uuid.uuid4()),
fully_qualified_name=str(uuid.uuid4())), self.tenant_id)
@ -86,12 +86,12 @@ class CatalogDBTestCase(base.MuranoWithDBTestCase):
def test_order_by_compound(self):
pkgs_a, pkgs_z = [], []
for i in range(5):
for _ in range(5):
package = api.package_upload(self._stub_package(
name='z',
fully_qualified_name=str(uuid.uuid4())), self.tenant_id)
pkgs_z.append(package)
for i in range(5):
for _ in range(5):
package = api.package_upload(self._stub_package(
name='a',
fully_qualified_name=str(uuid.uuid4())), self.tenant_id)
@ -113,7 +113,7 @@ class CatalogDBTestCase(base.MuranoWithDBTestCase):
checking that package order is correct.
"""
pkgs = []
for i in range(10):
for dummy in range(10):
package = api.package_upload(self._stub_package(
name=str(uuid.uuid4()),
fully_qualified_name=str(uuid.uuid4())), self.tenant_id)
@ -154,7 +154,7 @@ class CatalogDBTestCase(base.MuranoWithDBTestCase):
"""
pkgs = []
for i in range(10):
for dummy in range(10):
package = api.package_upload(self._stub_package(
name=str(uuid.uuid4()),
fully_qualified_name=str(uuid.uuid4())), self.tenant_id)
@ -188,7 +188,7 @@ class CatalogDBTestCase(base.MuranoWithDBTestCase):
"""
# TODO(kzaitsev): fix https://bugs.launchpad.net/murano/+bug/1448782
for i in range(10):
for dummy in range(10):
api.package_upload(self._stub_package(
fully_qualified_name=str(uuid.uuid4())), self.tenant_id)
res = api.package_search({}, self.context, limit=4)

View File

@ -75,7 +75,7 @@ class TestPackageLoader(package_loader.MuranoPackageLoader):
def _build_index(self, directory):
yamls = [os.path.join(dirpath, f)
for dirpath, dirnames, files in os.walk(directory)
for dirpath, _, files in os.walk(directory)
for f in fnmatch.filter(files, '*.yaml')]
for class_def_file in yamls:
self._load_class(class_def_file)