summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSergey Lukjanov <slukjanov@mirantis.com>2013-07-19 22:59:51 +0400
committerSergey Lukjanov <slukjanov@mirantis.com>2013-07-20 03:24:49 +0400
commit7bf8ee930b1838a1b1640912df0e2050bd9b96ae (patch)
treee58db93dfc0e87883762eea967dce733552cf07e /tests
parent3c69baf5c8db4b98df93c8ef5702d7df095d69ff (diff)
downloadoslo-7bf8ee930b1838a1b1640912df0e2050bd9b96ae.tar.gz
oslo-7bf8ee930b1838a1b1640912df0e2050bd9b96ae.tar.xz
oslo-7bf8ee930b1838a1b1640912df0e2050bd9b96ae.zip
Allow use of hacking 0.6.0 and enable new checks
There are only several errors after running hacking 0.6.0: * H501 Do not use locals() for string formatting * H231 Python 3.x incompatible 'except x,y:' construct Change-Id: Iacae482fda07507c3e7ce8e6da8dbb7bde699016
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/db/sqlalchemy/test_migrations.py20
-rw-r--r--tests/unit/rpc/common.py2
2 files changed, 12 insertions, 10 deletions
diff --git a/tests/unit/db/sqlalchemy/test_migrations.py b/tests/unit/db/sqlalchemy/test_migrations.py
index b466e2c..8428b1c 100644
--- a/tests/unit/db/sqlalchemy/test_migrations.py
+++ b/tests/unit/db/sqlalchemy/test_migrations.py
@@ -48,7 +48,8 @@ def _get_connect_string(backend, user, passwd, database):
raise Exception("Unrecognized backend: '%s'" % backend)
return ("%(backend)s://%(user)s:%(passwd)s@localhost/%(database)s"
- % locals())
+ % {'backend': backend, 'user': user, 'passwd': passwd,
+ 'database': database})
def _is_backend_avail(backend, user, passwd, database):
@@ -122,7 +123,7 @@ class BaseMigrationTestCase(test_utils.BaseTestCase):
defaults = cp.defaults()
for key, value in defaults.items():
self.test_databases[key] = value
- except ConfigParser.ParsingError, e:
+ except ConfigParser.ParsingError as e:
self.fail("Failed to read test_migrations.conf config "
"file. Got error: %s" % e)
else:
@@ -160,12 +161,12 @@ class BaseMigrationTestCase(test_utils.BaseTestCase):
sqlcmd = ("psql -w -U %(user)s -h %(host)s -c"
" '%(sql)s' -d template1")
- sql = ("drop database if exists %(database)s;") % locals()
- droptable = sqlcmd % locals()
+ sql = ("drop database if exists %s;") % database
+ droptable = sqlcmd % {'user': user, 'host': host, 'sql': sql}
self.execute_cmd(droptable)
- sql = ("create database %(database)s;") % locals()
- createtable = sqlcmd % locals()
+ sql = ("create database %s;") % database
+ createtable = sqlcmd % {'user': user, 'host': host, 'sql': sql}
self.execute_cmd(createtable)
os.unsetenv('PGPASSWORD')
@@ -190,10 +191,11 @@ class BaseMigrationTestCase(test_utils.BaseTestCase):
# than using SQLAlchemy to do this via MetaData...trust me.
(user, password, database, host) = \
get_db_connection_info(conn_pieces)
- sql = ("drop database if exists %(database)s; "
- "create database %(database)s;") % locals()
+ sql = ("drop database if exists %(db)s; "
+ "create database %(db)s;") % {'db': database}
cmd = ("mysql -u \"%(user)s\" -p\"%(password)s\" -h %(host)s "
- "-e \"%(sql)s\"") % locals()
+ "-e \"%(sql)s\"") % {'user': user, 'password': password,
+ 'host': host, 'sql': sql}
self.execute_cmd(cmd)
elif conn_string.startswith('postgresql'):
self._reset_pg(conn_pieces)
diff --git a/tests/unit/rpc/common.py b/tests/unit/rpc/common.py
index c4c21d8..2c343fe 100644
--- a/tests/unit/rpc/common.py
+++ b/tests/unit/rpc/common.py
@@ -206,7 +206,7 @@ class BaseRpcTestCase(test_utils.BaseTestCase):
def echo(context, queue, value):
"""Calls echo in the passed queue."""
LOG.debug(_("Nested received %(queue)s, %(value)s")
- % locals())
+ % {'queue': queue, 'value': value})
# TODO(comstud):
# so, it will replay the context and use the same REQID?
# that's bizarre.