From 1a2df89c05d33495d7e057dcdf0714d05beb1fc8 Mon Sep 17 00:00:00 2001 From: Ann Kamyshnikova Date: Tue, 25 Jun 2013 17:12:58 +0400 Subject: [PATCH] Enable H302 hacking check This change requires hacking >0.5.5 Change-Id: Ic36fa0502548335d433f3fbe663854523dd04397 --- openstack/common/crypto/utils.py | 10 +++++----- openstack/common/db/exception.py | 2 +- openstack/common/db/sqlalchemy/models.py | 4 ++-- openstack/common/db/sqlalchemy/session.py | 2 +- openstack/common/db/sqlalchemy/utils.py | 2 +- openstack/common/deprecated/wsgi.py | 2 +- openstack/common/eventlet_backdoor.py | 2 +- openstack/common/exception.py | 2 +- openstack/common/excutils.py | 2 +- openstack/common/fileutils.py | 2 +- openstack/common/lockutils.py | 2 +- openstack/common/log.py | 2 +- openstack/common/loopingcall.py | 2 +- openstack/common/middleware/sizelimit.py | 2 +- openstack/common/notifier/api.py | 2 +- openstack/common/notifier/rpc_notifier.py | 2 +- openstack/common/notifier/rpc_notifier2.py | 2 +- openstack/common/periodic_task.py | 2 +- openstack/common/policy.py | 2 +- openstack/common/processutils.py | 2 +- openstack/common/rpc/__init__.py | 2 +- openstack/common/rpc/amqp.py | 2 +- openstack/common/rpc/common.py | 2 +- openstack/common/rpc/impl_kombu.py | 2 +- openstack/common/rpc/impl_qpid.py | 2 +- openstack/common/rpc/impl_zmq.py | 2 +- openstack/common/rpc/matchmaker.py | 2 +- openstack/common/rpc/matchmaker_ring.py | 2 +- openstack/common/rpc/service.py | 2 +- openstack/common/service.py | 2 +- openstack/common/sslutils.py | 2 +- openstack/common/strutils.py | 2 +- openstack/common/threadgroup.py | 6 +++--- tests/unit/middleware/test_sizelimit.py | 10 +++++----- tests/unit/rpc/common.py | 2 +- tests/unit/rpc/test_zmq.py | 2 +- tests/unit/test_jsonutils.py | 4 ++-- tests/unit/test_log.py | 9 +++++---- tests/unit/test_policy.py | 6 +++--- tests/unit/test_processutils.py | 8 ++++---- tox.ini | 1 - 41 files changed, 61 insertions(+), 61 deletions(-) diff --git a/openstack/common/crypto/utils.py b/openstack/common/crypto/utils.py index 61c1a50d3..ecf38ad92 100644 --- a/openstack/common/crypto/utils.py +++ b/openstack/common/crypto/utils.py @@ -19,8 +19,8 @@ import base64 from Crypto.Hash import HMAC from Crypto import Random -from openstack.common.gettextutils import _ -from openstack.common.importutils import import_module +from openstack.common.gettextutils import _ # noqa +from openstack.common import importutils class CryptoutilsException(Exception): @@ -54,7 +54,7 @@ class HKDF(object): """ def __init__(self, hashtype='SHA256'): - self.hashfn = import_module('Crypto.Hash.' + hashtype) + self.hashfn = importutils.import_module('Crypto.Hash.' + hashtype) self.max_okm_length = 255 * self.hashfn.digest_size def extract(self, ikm, salt=None): @@ -107,8 +107,8 @@ class SymmetricCrypto(object): """ def __init__(self, enctype='AES', hashtype='SHA256'): - self.cipher = import_module('Crypto.Cipher.' + enctype) - self.hashfn = import_module('Crypto.Hash.' + hashtype) + self.cipher = importutils.import_module('Crypto.Cipher.' + enctype) + self.hashfn = importutils.import_module('Crypto.Hash.' + hashtype) def new_key(self, size): return Random.new().read(size) diff --git a/openstack/common/db/exception.py b/openstack/common/db/exception.py index 8588d851e..69905da1c 100644 --- a/openstack/common/db/exception.py +++ b/openstack/common/db/exception.py @@ -18,7 +18,7 @@ """DB related custom exceptions.""" -from openstack.common.gettextutils import _ +from openstack.common.gettextutils import _ # noqa class DBError(Exception): diff --git a/openstack/common/db/sqlalchemy/models.py b/openstack/common/db/sqlalchemy/models.py index f61bb390b..fb5a3fa3f 100644 --- a/openstack/common/db/sqlalchemy/models.py +++ b/openstack/common/db/sqlalchemy/models.py @@ -26,7 +26,7 @@ from sqlalchemy import Column, Integer from sqlalchemy import DateTime from sqlalchemy.orm import object_mapper -from openstack.common.db.sqlalchemy.session import get_session +from openstack.common.db.sqlalchemy import session as sa from openstack.common import timeutils @@ -37,7 +37,7 @@ class ModelBase(object): def save(self, session=None): """Save this object.""" if not session: - session = get_session() + session = sa.get_session() # NOTE(boris-42): This part of code should be look like: # sesssion.add(self) # session.flush() diff --git a/openstack/common/db/sqlalchemy/session.py b/openstack/common/db/sqlalchemy/session.py index 7400b1706..59bcb90c4 100644 --- a/openstack/common/db/sqlalchemy/session.py +++ b/openstack/common/db/sqlalchemy/session.py @@ -256,7 +256,7 @@ from sqlalchemy.pool import NullPool, StaticPool from sqlalchemy.sql.expression import literal_column from openstack.common.db import exception -from openstack.common.gettextutils import _ +from openstack.common.gettextutils import _ # noqa from openstack.common import log as logging from openstack.common import timeutils diff --git a/openstack/common/db/sqlalchemy/utils.py b/openstack/common/db/sqlalchemy/utils.py index e89ec10ee..07030c5f6 100644 --- a/openstack/common/db/sqlalchemy/utils.py +++ b/openstack/common/db/sqlalchemy/utils.py @@ -22,7 +22,7 @@ import sqlalchemy -from openstack.common.gettextutils import _ +from openstack.common.gettextutils import _ # noqa from openstack.common import log as logging diff --git a/openstack/common/deprecated/wsgi.py b/openstack/common/deprecated/wsgi.py index cf2e9ae1c..a9530b33f 100644 --- a/openstack/common/deprecated/wsgi.py +++ b/openstack/common/deprecated/wsgi.py @@ -36,7 +36,7 @@ from xml.dom import minidom from xml.parsers import expat from openstack.common import exception -from openstack.common.gettextutils import _ +from openstack.common.gettextutils import _ # noqa from openstack.common import jsonutils from openstack.common import log as logging from openstack.common import service diff --git a/openstack/common/eventlet_backdoor.py b/openstack/common/eventlet_backdoor.py index f2102d6ae..9d3227cc6 100644 --- a/openstack/common/eventlet_backdoor.py +++ b/openstack/common/eventlet_backdoor.py @@ -31,7 +31,7 @@ import eventlet.backdoor import greenlet from oslo.config import cfg -from openstack.common.gettextutils import _ +from openstack.common.gettextutils import _ # noqa from openstack.common import log as logging help_for_backdoor_port = 'Acceptable ' + \ diff --git a/openstack/common/exception.py b/openstack/common/exception.py index f6c84637d..fdf17b2b6 100644 --- a/openstack/common/exception.py +++ b/openstack/common/exception.py @@ -21,7 +21,7 @@ Exceptions common to OpenStack projects import logging -from openstack.common.gettextutils import _ +from openstack.common.gettextutils import _ # noqa _FATAL_EXCEPTION_FORMAT_ERRORS = False diff --git a/openstack/common/excutils.py b/openstack/common/excutils.py index 336e14788..abe6f8772 100644 --- a/openstack/common/excutils.py +++ b/openstack/common/excutils.py @@ -24,7 +24,7 @@ import sys import time import traceback -from openstack.common.gettextutils import _ +from openstack.common.gettextutils import _ # noqa class save_and_reraise_exception(object): diff --git a/openstack/common/fileutils.py b/openstack/common/fileutils.py index 9f8807f87..7a04e8f29 100644 --- a/openstack/common/fileutils.py +++ b/openstack/common/fileutils.py @@ -21,7 +21,7 @@ import errno import os from openstack.common import excutils -from openstack.common.gettextutils import _ +from openstack.common.gettextutils import _ # noqa from openstack.common import log as logging LOG = logging.getLogger(__name__) diff --git a/openstack/common/lockutils.py b/openstack/common/lockutils.py index 27525ce8c..be362f83f 100644 --- a/openstack/common/lockutils.py +++ b/openstack/common/lockutils.py @@ -28,7 +28,7 @@ from eventlet import semaphore from oslo.config import cfg from openstack.common import fileutils -from openstack.common.gettextutils import _ +from openstack.common.gettextutils import _ # noqa from openstack.common import local from openstack.common import log as logging diff --git a/openstack/common/log.py b/openstack/common/log.py index 0447a526e..465886b24 100644 --- a/openstack/common/log.py +++ b/openstack/common/log.py @@ -42,7 +42,7 @@ import traceback from oslo.config import cfg -from openstack.common.gettextutils import _ +from openstack.common.gettextutils import _ # noqa from openstack.common import importutils from openstack.common import jsonutils from openstack.common import local diff --git a/openstack/common/loopingcall.py b/openstack/common/loopingcall.py index 168843218..71dedd850 100644 --- a/openstack/common/loopingcall.py +++ b/openstack/common/loopingcall.py @@ -22,7 +22,7 @@ import sys from eventlet import event from eventlet import greenthread -from openstack.common.gettextutils import _ +from openstack.common.gettextutils import _ # noqa from openstack.common import log as logging from openstack.common import timeutils diff --git a/openstack/common/middleware/sizelimit.py b/openstack/common/middleware/sizelimit.py index 96a1fbfef..ecbdde1d5 100644 --- a/openstack/common/middleware/sizelimit.py +++ b/openstack/common/middleware/sizelimit.py @@ -23,7 +23,7 @@ import webob.dec import webob.exc from openstack.common.deprecated import wsgi -from openstack.common.gettextutils import _ +from openstack.common.gettextutils import _ # noqa from openstack.common.middleware import base diff --git a/openstack/common/notifier/api.py b/openstack/common/notifier/api.py index dc4f57897..df89f67b3 100644 --- a/openstack/common/notifier/api.py +++ b/openstack/common/notifier/api.py @@ -19,7 +19,7 @@ import uuid from oslo.config import cfg from openstack.common import context -from openstack.common.gettextutils import _ +from openstack.common.gettextutils import _ # noqa from openstack.common import importutils from openstack.common import jsonutils from openstack.common import log as logging diff --git a/openstack/common/notifier/rpc_notifier.py b/openstack/common/notifier/rpc_notifier.py index 17bbc9a21..6bfc33334 100644 --- a/openstack/common/notifier/rpc_notifier.py +++ b/openstack/common/notifier/rpc_notifier.py @@ -16,7 +16,7 @@ from oslo.config import cfg from openstack.common import context as req_context -from openstack.common.gettextutils import _ +from openstack.common.gettextutils import _ # noqa from openstack.common import log as logging from openstack.common import rpc diff --git a/openstack/common/notifier/rpc_notifier2.py b/openstack/common/notifier/rpc_notifier2.py index 38fe33b56..55dd7801e 100644 --- a/openstack/common/notifier/rpc_notifier2.py +++ b/openstack/common/notifier/rpc_notifier2.py @@ -18,7 +18,7 @@ from oslo.config import cfg from openstack.common import context as req_context -from openstack.common.gettextutils import _ +from openstack.common.gettextutils import _ # noqa from openstack.common import log as logging from openstack.common import rpc diff --git a/openstack/common/periodic_task.py b/openstack/common/periodic_task.py index 4fbb0fe8a..1c19846bb 100644 --- a/openstack/common/periodic_task.py +++ b/openstack/common/periodic_task.py @@ -18,7 +18,7 @@ import time from oslo.config import cfg -from openstack.common.gettextutils import _ +from openstack.common.gettextutils import _ # noqa from openstack.common import log as logging from openstack.common import timeutils diff --git a/openstack/common/policy.py b/openstack/common/policy.py index 40e5a6e6a..d4d9aa19c 100644 --- a/openstack/common/policy.py +++ b/openstack/common/policy.py @@ -65,7 +65,7 @@ from oslo.config import cfg import six from openstack.common import fileutils -from openstack.common.gettextutils import _ +from openstack.common.gettextutils import _ # noqa from openstack.common import jsonutils from openstack.common import log as logging diff --git a/openstack/common/processutils.py b/openstack/common/processutils.py index 541705555..13f62228c 100644 --- a/openstack/common/processutils.py +++ b/openstack/common/processutils.py @@ -27,7 +27,7 @@ import signal from eventlet.green import subprocess from eventlet import greenthread -from openstack.common.gettextutils import _ +from openstack.common.gettextutils import _ # noqa from openstack.common import log as logging diff --git a/openstack/common/rpc/__init__.py b/openstack/common/rpc/__init__.py index 325c03690..e39f29401 100644 --- a/openstack/common/rpc/__init__.py +++ b/openstack/common/rpc/__init__.py @@ -29,7 +29,7 @@ import inspect from oslo.config import cfg -from openstack.common.gettextutils import _ +from openstack.common.gettextutils import _ # noqa from openstack.common import importutils from openstack.common import local from openstack.common import log as logging diff --git a/openstack/common/rpc/amqp.py b/openstack/common/rpc/amqp.py index c3e4e265b..23e007939 100644 --- a/openstack/common/rpc/amqp.py +++ b/openstack/common/rpc/amqp.py @@ -36,7 +36,7 @@ from eventlet import queue from eventlet import semaphore from openstack.common import excutils -from openstack.common.gettextutils import _ +from openstack.common.gettextutils import _ # noqa from openstack.common import local from openstack.common import log as logging from openstack.common.rpc import common as rpc_common diff --git a/openstack/common/rpc/common.py b/openstack/common/rpc/common.py index e116e9264..0d8548883 100644 --- a/openstack/common/rpc/common.py +++ b/openstack/common/rpc/common.py @@ -24,7 +24,7 @@ import traceback from oslo.config import cfg import six -from openstack.common.gettextutils import _ +from openstack.common.gettextutils import _ # noqa from openstack.common import importutils from openstack.common import jsonutils from openstack.common import local diff --git a/openstack/common/rpc/impl_kombu.py b/openstack/common/rpc/impl_kombu.py index d1d04e0f4..67022ea36 100644 --- a/openstack/common/rpc/impl_kombu.py +++ b/openstack/common/rpc/impl_kombu.py @@ -30,7 +30,7 @@ import kombu.messaging from oslo.config import cfg from openstack.common import excutils -from openstack.common.gettextutils import _ +from openstack.common.gettextutils import _ # noqa from openstack.common import network_utils from openstack.common.rpc import amqp as rpc_amqp from openstack.common.rpc import common as rpc_common diff --git a/openstack/common/rpc/impl_qpid.py b/openstack/common/rpc/impl_qpid.py index c988ae887..dbfbddea9 100644 --- a/openstack/common/rpc/impl_qpid.py +++ b/openstack/common/rpc/impl_qpid.py @@ -25,7 +25,7 @@ import greenlet from oslo.config import cfg from openstack.common import excutils -from openstack.common.gettextutils import _ +from openstack.common.gettextutils import _ # noqa from openstack.common import importutils from openstack.common import jsonutils from openstack.common import log as logging diff --git a/openstack/common/rpc/impl_zmq.py b/openstack/common/rpc/impl_zmq.py index fb8fcd244..33d5cb64b 100644 --- a/openstack/common/rpc/impl_zmq.py +++ b/openstack/common/rpc/impl_zmq.py @@ -27,7 +27,7 @@ import greenlet from oslo.config import cfg from openstack.common import excutils -from openstack.common.gettextutils import _ +from openstack.common.gettextutils import _ # noqa from openstack.common import importutils from openstack.common import jsonutils from openstack.common.rpc import common as rpc_common diff --git a/openstack/common/rpc/matchmaker.py b/openstack/common/rpc/matchmaker.py index e51636d7c..e80ab37a5 100644 --- a/openstack/common/rpc/matchmaker.py +++ b/openstack/common/rpc/matchmaker.py @@ -23,7 +23,7 @@ import contextlib import eventlet from oslo.config import cfg -from openstack.common.gettextutils import _ +from openstack.common.gettextutils import _ # noqa from openstack.common import log as logging diff --git a/openstack/common/rpc/matchmaker_ring.py b/openstack/common/rpc/matchmaker_ring.py index 2f1f79b5d..45a095f34 100644 --- a/openstack/common/rpc/matchmaker_ring.py +++ b/openstack/common/rpc/matchmaker_ring.py @@ -23,7 +23,7 @@ import json from oslo.config import cfg -from openstack.common.gettextutils import _ +from openstack.common.gettextutils import _ # noqa from openstack.common import log as logging from openstack.common.rpc import matchmaker as mm diff --git a/openstack/common/rpc/service.py b/openstack/common/rpc/service.py index 3f51d0b75..e60cd1f38 100644 --- a/openstack/common/rpc/service.py +++ b/openstack/common/rpc/service.py @@ -17,7 +17,7 @@ # License for the specific language governing permissions and limitations # under the License. -from openstack.common.gettextutils import _ +from openstack.common.gettextutils import _ # noqa from openstack.common import log as logging from openstack.common import rpc from openstack.common.rpc import dispatcher as rpc_dispatcher diff --git a/openstack/common/service.py b/openstack/common/service.py index d5c560466..24ab5e978 100644 --- a/openstack/common/service.py +++ b/openstack/common/service.py @@ -32,7 +32,7 @@ import logging as std_logging from oslo.config import cfg from openstack.common import eventlet_backdoor -from openstack.common.gettextutils import _ +from openstack.common.gettextutils import _ # noqa from openstack.common import importutils from openstack.common import log as logging from openstack.common import threadgroup diff --git a/openstack/common/sslutils.py b/openstack/common/sslutils.py index 252da72dd..23f8bbf6a 100644 --- a/openstack/common/sslutils.py +++ b/openstack/common/sslutils.py @@ -19,7 +19,7 @@ import ssl from oslo.config import cfg -from openstack.common.gettextutils import _ +from openstack.common.gettextutils import _ # noqa ssl_opts = [ diff --git a/openstack/common/strutils.py b/openstack/common/strutils.py index 0ba9b44d8..971ffe3c7 100644 --- a/openstack/common/strutils.py +++ b/openstack/common/strutils.py @@ -25,7 +25,7 @@ import unicodedata import six -from openstack.common.gettextutils import _ +from openstack.common.gettextutils import _ # noqa # Used for looking up extensions of text diff --git a/openstack/common/threadgroup.py b/openstack/common/threadgroup.py index 877059c2f..6d1afe77b 100644 --- a/openstack/common/threadgroup.py +++ b/openstack/common/threadgroup.py @@ -14,7 +14,7 @@ # License for the specific language governing permissions and limitations # under the License. -from eventlet import greenlet +import eventlet from eventlet import greenpool from eventlet import greenthread @@ -105,7 +105,7 @@ class ThreadGroup(object): for x in self.timers: try: x.wait() - except greenlet.GreenletExit: + except eventlet.greenlet.GreenletExit: pass except Exception as ex: LOG.exception(ex) @@ -115,7 +115,7 @@ class ThreadGroup(object): continue try: x.wait() - except greenlet.GreenletExit: + except eventlet.greenlet.GreenletExit: pass except Exception as ex: LOG.exception(ex) diff --git a/tests/unit/middleware/test_sizelimit.py b/tests/unit/middleware/test_sizelimit.py index 22098d07e..7579659a2 100644 --- a/tests/unit/middleware/test_sizelimit.py +++ b/tests/unit/middleware/test_sizelimit.py @@ -13,7 +13,7 @@ # under the License. from oslo.config import cfg -from six import StringIO +import six import webob from openstack.common.middleware import sizelimit @@ -28,14 +28,14 @@ class TestLimitingReader(utils.BaseTestCase): def test_limiting_reader(self): BYTES = 1024 bytes_read = 0 - data = StringIO("*" * BYTES) + data = six.StringIO("*" * BYTES) for chunk in sizelimit.LimitingReader(data, BYTES): bytes_read += len(chunk) self.assertEquals(bytes_read, BYTES) bytes_read = 0 - data = StringIO("*" * BYTES) + data = six.StringIO("*" * BYTES) reader = sizelimit.LimitingReader(data, BYTES) byte = reader.read(1) while len(byte) != 0: @@ -49,7 +49,7 @@ class TestLimitingReader(utils.BaseTestCase): def _consume_all_iter(): bytes_read = 0 - data = StringIO("*" * BYTES) + data = six.StringIO("*" * BYTES) for chunk in sizelimit.LimitingReader(data, BYTES - 1): bytes_read += len(chunk) @@ -58,7 +58,7 @@ class TestLimitingReader(utils.BaseTestCase): def _consume_all_read(): bytes_read = 0 - data = StringIO("*" * BYTES) + data = six.StringIO("*" * BYTES) reader = sizelimit.LimitingReader(data, BYTES - 1) byte = reader.read(1) while len(byte) != 0: diff --git a/tests/unit/rpc/common.py b/tests/unit/rpc/common.py index 32f2a9bb2..c4c21d8d2 100644 --- a/tests/unit/rpc/common.py +++ b/tests/unit/rpc/common.py @@ -27,7 +27,7 @@ import eventlet from oslo.config import cfg from openstack.common import exception -from openstack.common.gettextutils import _ +from openstack.common.gettextutils import _ # noqa from openstack.common.rpc import common as rpc_common from openstack.common.rpc import dispatcher as rpc_dispatcher from tests import utils as test_utils diff --git a/tests/unit/rpc/test_zmq.py b/tests/unit/rpc/test_zmq.py index c87a040f2..5f6e9b08c 100644 --- a/tests/unit/rpc/test_zmq.py +++ b/tests/unit/rpc/test_zmq.py @@ -29,7 +29,7 @@ import socket import fixtures from oslo.config import cfg -from openstack.common.gettextutils import _ +from openstack.common.gettextutils import _ # noqa from tests.unit.rpc import common try: diff --git a/tests/unit/test_jsonutils.py b/tests/unit/test_jsonutils.py index 28d588ee6..5dc23f76b 100644 --- a/tests/unit/test_jsonutils.py +++ b/tests/unit/test_jsonutils.py @@ -19,7 +19,7 @@ import datetime import xmlrpclib import netaddr -from six import StringIO +import six from openstack.common import jsonutils from tests import utils @@ -34,7 +34,7 @@ class JSONUtilsTestCase(utils.BaseTestCase): self.assertEqual(jsonutils.loads('{"a": "b"}'), {'a': 'b'}) def test_load(self): - x = StringIO('{"a": "b"}') + x = six.StringIO('{"a": "b"}') self.assertEqual(jsonutils.load(x), {'a': 'b'}) diff --git a/tests/unit/test_log.py b/tests/unit/test_log.py index e58bd7dad..8f40f75f9 100644 --- a/tests/unit/test_log.py +++ b/tests/unit/test_log.py @@ -21,12 +21,12 @@ import sys import tempfile from oslo.config import cfg -from six import StringIO +import six from openstack.common import context from openstack.common import jsonutils from openstack.common import log -from openstack.common.log_handler import PublishErrorsHandler +from openstack.common import log_handler from openstack.common.notifier import api as notifier from tests import utils as test_utils @@ -131,7 +131,8 @@ class PublishErrorsHandlerTestCase(test_utils.BaseTestCase): """Tests for log.PublishErrorsHandler""" def setUp(self): super(PublishErrorsHandlerTestCase, self).setUp() - self.publiserrorshandler = PublishErrorsHandler(logging.ERROR) + self.publiserrorshandler = log_handler.\ + PublishErrorsHandler(logging.ERROR) def test_emit_cfg_log_notifier_in_notifier_drivers(self): self.config(notification_driver=[ @@ -367,7 +368,7 @@ class SetDefaultsTestCase(test_utils.BaseTestCase): class LogConfigOptsTestCase(test_utils.BaseTestCase): def test_print_help(self): - f = StringIO() + f = six.StringIO() CONF([]) CONF.print_help(file=f) self.assertTrue('debug' in f.getvalue()) diff --git a/tests/unit/test_policy.py b/tests/unit/test_policy.py index 33b291a82..24b23a451 100644 --- a/tests/unit/test_policy.py +++ b/tests/unit/test_policy.py @@ -23,7 +23,7 @@ import urllib2 import mock from oslo.config import cfg -from six import StringIO +import six from openstack.common import jsonutils from openstack.common import policy @@ -779,7 +779,7 @@ class HttpCheckTestCase(PolicyBaseTestCase): return result @mock.patch.object(urllib2, 'urlopen', - return_value=StringIO('True')) + return_value=six.StringIO('True')) def test_accept(self, mock_urlopen): check = policy.HttpCheck('http', '//example.com/%(name)s') @@ -798,7 +798,7 @@ class HttpCheckTestCase(PolicyBaseTestCase): )) @mock.patch.object(urllib2, 'urlopen', - return_value=StringIO('other')) + return_value=six.StringIO('other')) def test_reject(self, mock_urlopen): check = policy.HttpCheck('http', '//example.com/%(name)s') diff --git a/tests/unit/test_processutils.py b/tests/unit/test_processutils.py index 4466d710d..7c6e11c6b 100644 --- a/tests/unit/test_processutils.py +++ b/tests/unit/test_processutils.py @@ -21,7 +21,7 @@ import fixtures import os import tempfile -from six import StringIO +import six from openstack.common import processutils from tests import utils @@ -214,7 +214,7 @@ class FakeSshChannel(object): return self.rc -class FakeSshStream(StringIO): +class FakeSshStream(six.StringIO): def setup_channel(self, rc): self.channel = FakeSshChannel(rc) @@ -226,9 +226,9 @@ class FakeSshConnection(object): def exec_command(self, cmd): stdout = FakeSshStream('stdout') stdout.setup_channel(self.rc) - return (StringIO(), + return (six.StringIO(), stdout, - StringIO('stderr')) + six.StringIO('stderr')) class SshExecuteTestCase(utils.BaseTestCase): diff --git a/tox.ini b/tox.ini index ad939f141..2b5e3eba7 100644 --- a/tox.ini +++ b/tox.ini @@ -13,7 +13,6 @@ commands = [flake8] show-source = True -ignore = H302 exclude = .venv,.tox,dist,doc,*.egg,.update-venv [testenv:pep8]