Enable H302 hacking check
This change requires hacking >0.5.5 Change-Id: Ic36fa0502548335d433f3fbe663854523dd04397
This commit is contained in:
parent
dee8afb7f8
commit
1a2df89c05
|
@ -19,8 +19,8 @@ import base64
|
||||||
from Crypto.Hash import HMAC
|
from Crypto.Hash import HMAC
|
||||||
from Crypto import Random
|
from Crypto import Random
|
||||||
|
|
||||||
from openstack.common.gettextutils import _
|
from openstack.common.gettextutils import _ # noqa
|
||||||
from openstack.common.importutils import import_module
|
from openstack.common import importutils
|
||||||
|
|
||||||
|
|
||||||
class CryptoutilsException(Exception):
|
class CryptoutilsException(Exception):
|
||||||
|
@ -54,7 +54,7 @@ class HKDF(object):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, hashtype='SHA256'):
|
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
|
self.max_okm_length = 255 * self.hashfn.digest_size
|
||||||
|
|
||||||
def extract(self, ikm, salt=None):
|
def extract(self, ikm, salt=None):
|
||||||
|
@ -107,8 +107,8 @@ class SymmetricCrypto(object):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, enctype='AES', hashtype='SHA256'):
|
def __init__(self, enctype='AES', hashtype='SHA256'):
|
||||||
self.cipher = import_module('Crypto.Cipher.' + enctype)
|
self.cipher = importutils.import_module('Crypto.Cipher.' + enctype)
|
||||||
self.hashfn = import_module('Crypto.Hash.' + hashtype)
|
self.hashfn = importutils.import_module('Crypto.Hash.' + hashtype)
|
||||||
|
|
||||||
def new_key(self, size):
|
def new_key(self, size):
|
||||||
return Random.new().read(size)
|
return Random.new().read(size)
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
"""DB related custom exceptions."""
|
"""DB related custom exceptions."""
|
||||||
|
|
||||||
from openstack.common.gettextutils import _
|
from openstack.common.gettextutils import _ # noqa
|
||||||
|
|
||||||
|
|
||||||
class DBError(Exception):
|
class DBError(Exception):
|
||||||
|
|
|
@ -26,7 +26,7 @@ from sqlalchemy import Column, Integer
|
||||||
from sqlalchemy import DateTime
|
from sqlalchemy import DateTime
|
||||||
from sqlalchemy.orm import object_mapper
|
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
|
from openstack.common import timeutils
|
||||||
|
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ class ModelBase(object):
|
||||||
def save(self, session=None):
|
def save(self, session=None):
|
||||||
"""Save this object."""
|
"""Save this object."""
|
||||||
if not session:
|
if not session:
|
||||||
session = get_session()
|
session = sa.get_session()
|
||||||
# NOTE(boris-42): This part of code should be look like:
|
# NOTE(boris-42): This part of code should be look like:
|
||||||
# sesssion.add(self)
|
# sesssion.add(self)
|
||||||
# session.flush()
|
# session.flush()
|
||||||
|
|
|
@ -256,7 +256,7 @@ from sqlalchemy.pool import NullPool, StaticPool
|
||||||
from sqlalchemy.sql.expression import literal_column
|
from sqlalchemy.sql.expression import literal_column
|
||||||
|
|
||||||
from openstack.common.db import exception
|
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 log as logging
|
||||||
from openstack.common import timeutils
|
from openstack.common import timeutils
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
|
|
||||||
from openstack.common.gettextutils import _
|
from openstack.common.gettextutils import _ # noqa
|
||||||
from openstack.common import log as logging
|
from openstack.common import log as logging
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ from xml.dom import minidom
|
||||||
from xml.parsers import expat
|
from xml.parsers import expat
|
||||||
|
|
||||||
from openstack.common import exception
|
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 jsonutils
|
||||||
from openstack.common import log as logging
|
from openstack.common import log as logging
|
||||||
from openstack.common import service
|
from openstack.common import service
|
||||||
|
|
|
@ -31,7 +31,7 @@ import eventlet.backdoor
|
||||||
import greenlet
|
import greenlet
|
||||||
from oslo.config import cfg
|
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 log as logging
|
||||||
|
|
||||||
help_for_backdoor_port = 'Acceptable ' + \
|
help_for_backdoor_port = 'Acceptable ' + \
|
||||||
|
|
|
@ -21,7 +21,7 @@ Exceptions common to OpenStack projects
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from openstack.common.gettextutils import _
|
from openstack.common.gettextutils import _ # noqa
|
||||||
|
|
||||||
_FATAL_EXCEPTION_FORMAT_ERRORS = False
|
_FATAL_EXCEPTION_FORMAT_ERRORS = False
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ import sys
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
from openstack.common.gettextutils import _
|
from openstack.common.gettextutils import _ # noqa
|
||||||
|
|
||||||
|
|
||||||
class save_and_reraise_exception(object):
|
class save_and_reraise_exception(object):
|
||||||
|
|
|
@ -21,7 +21,7 @@ import errno
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from openstack.common import excutils
|
from openstack.common import excutils
|
||||||
from openstack.common.gettextutils import _
|
from openstack.common.gettextutils import _ # noqa
|
||||||
from openstack.common import log as logging
|
from openstack.common import log as logging
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
|
@ -28,7 +28,7 @@ from eventlet import semaphore
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
from openstack.common import fileutils
|
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 local
|
||||||
from openstack.common import log as logging
|
from openstack.common import log as logging
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ import traceback
|
||||||
|
|
||||||
from oslo.config import cfg
|
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 importutils
|
||||||
from openstack.common import jsonutils
|
from openstack.common import jsonutils
|
||||||
from openstack.common import local
|
from openstack.common import local
|
||||||
|
|
|
@ -22,7 +22,7 @@ import sys
|
||||||
from eventlet import event
|
from eventlet import event
|
||||||
from eventlet import greenthread
|
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 log as logging
|
||||||
from openstack.common import timeutils
|
from openstack.common import timeutils
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ import webob.dec
|
||||||
import webob.exc
|
import webob.exc
|
||||||
|
|
||||||
from openstack.common.deprecated import wsgi
|
from openstack.common.deprecated import wsgi
|
||||||
from openstack.common.gettextutils import _
|
from openstack.common.gettextutils import _ # noqa
|
||||||
from openstack.common.middleware import base
|
from openstack.common.middleware import base
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ import uuid
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
from openstack.common import context
|
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 importutils
|
||||||
from openstack.common import jsonutils
|
from openstack.common import jsonutils
|
||||||
from openstack.common import log as logging
|
from openstack.common import log as logging
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
from openstack.common import context as req_context
|
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 log as logging
|
||||||
from openstack.common import rpc
|
from openstack.common import rpc
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
from openstack.common import context as req_context
|
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 log as logging
|
||||||
from openstack.common import rpc
|
from openstack.common import rpc
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ import time
|
||||||
|
|
||||||
from oslo.config import cfg
|
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 log as logging
|
||||||
from openstack.common import timeutils
|
from openstack.common import timeutils
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ from oslo.config import cfg
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from openstack.common import fileutils
|
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 jsonutils
|
||||||
from openstack.common import log as logging
|
from openstack.common import log as logging
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ import signal
|
||||||
from eventlet.green import subprocess
|
from eventlet.green import subprocess
|
||||||
from eventlet import greenthread
|
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 log as logging
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ import inspect
|
||||||
|
|
||||||
from oslo.config import cfg
|
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 importutils
|
||||||
from openstack.common import local
|
from openstack.common import local
|
||||||
from openstack.common import log as logging
|
from openstack.common import log as logging
|
||||||
|
|
|
@ -36,7 +36,7 @@ from eventlet import queue
|
||||||
from eventlet import semaphore
|
from eventlet import semaphore
|
||||||
|
|
||||||
from openstack.common import excutils
|
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 local
|
||||||
from openstack.common import log as logging
|
from openstack.common import log as logging
|
||||||
from openstack.common.rpc import common as rpc_common
|
from openstack.common.rpc import common as rpc_common
|
||||||
|
|
|
@ -24,7 +24,7 @@ import traceback
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from openstack.common.gettextutils import _
|
from openstack.common.gettextutils import _ # noqa
|
||||||
from openstack.common import importutils
|
from openstack.common import importutils
|
||||||
from openstack.common import jsonutils
|
from openstack.common import jsonutils
|
||||||
from openstack.common import local
|
from openstack.common import local
|
||||||
|
|
|
@ -30,7 +30,7 @@ import kombu.messaging
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
from openstack.common import excutils
|
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 import network_utils
|
||||||
from openstack.common.rpc import amqp as rpc_amqp
|
from openstack.common.rpc import amqp as rpc_amqp
|
||||||
from openstack.common.rpc import common as rpc_common
|
from openstack.common.rpc import common as rpc_common
|
||||||
|
|
|
@ -25,7 +25,7 @@ import greenlet
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
from openstack.common import excutils
|
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 importutils
|
||||||
from openstack.common import jsonutils
|
from openstack.common import jsonutils
|
||||||
from openstack.common import log as logging
|
from openstack.common import log as logging
|
||||||
|
|
|
@ -27,7 +27,7 @@ import greenlet
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
from openstack.common import excutils
|
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 importutils
|
||||||
from openstack.common import jsonutils
|
from openstack.common import jsonutils
|
||||||
from openstack.common.rpc import common as rpc_common
|
from openstack.common.rpc import common as rpc_common
|
||||||
|
|
|
@ -23,7 +23,7 @@ import contextlib
|
||||||
import eventlet
|
import eventlet
|
||||||
from oslo.config import cfg
|
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 log as logging
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ import json
|
||||||
|
|
||||||
from oslo.config import cfg
|
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 log as logging
|
||||||
from openstack.common.rpc import matchmaker as mm
|
from openstack.common.rpc import matchmaker as mm
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# 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 log as logging
|
||||||
from openstack.common import rpc
|
from openstack.common import rpc
|
||||||
from openstack.common.rpc import dispatcher as rpc_dispatcher
|
from openstack.common.rpc import dispatcher as rpc_dispatcher
|
||||||
|
|
|
@ -32,7 +32,7 @@ import logging as std_logging
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
from openstack.common import eventlet_backdoor
|
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 importutils
|
||||||
from openstack.common import log as logging
|
from openstack.common import log as logging
|
||||||
from openstack.common import threadgroup
|
from openstack.common import threadgroup
|
||||||
|
|
|
@ -19,7 +19,7 @@ import ssl
|
||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
from openstack.common.gettextutils import _
|
from openstack.common.gettextutils import _ # noqa
|
||||||
|
|
||||||
|
|
||||||
ssl_opts = [
|
ssl_opts = [
|
||||||
|
|
|
@ -25,7 +25,7 @@ import unicodedata
|
||||||
|
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from openstack.common.gettextutils import _
|
from openstack.common.gettextutils import _ # noqa
|
||||||
|
|
||||||
|
|
||||||
# Used for looking up extensions of text
|
# Used for looking up extensions of text
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from eventlet import greenlet
|
import eventlet
|
||||||
from eventlet import greenpool
|
from eventlet import greenpool
|
||||||
from eventlet import greenthread
|
from eventlet import greenthread
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ class ThreadGroup(object):
|
||||||
for x in self.timers:
|
for x in self.timers:
|
||||||
try:
|
try:
|
||||||
x.wait()
|
x.wait()
|
||||||
except greenlet.GreenletExit:
|
except eventlet.greenlet.GreenletExit:
|
||||||
pass
|
pass
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
LOG.exception(ex)
|
LOG.exception(ex)
|
||||||
|
@ -115,7 +115,7 @@ class ThreadGroup(object):
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
x.wait()
|
x.wait()
|
||||||
except greenlet.GreenletExit:
|
except eventlet.greenlet.GreenletExit:
|
||||||
pass
|
pass
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
LOG.exception(ex)
|
LOG.exception(ex)
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
from six import StringIO
|
import six
|
||||||
import webob
|
import webob
|
||||||
|
|
||||||
from openstack.common.middleware import sizelimit
|
from openstack.common.middleware import sizelimit
|
||||||
|
@ -28,14 +28,14 @@ class TestLimitingReader(utils.BaseTestCase):
|
||||||
def test_limiting_reader(self):
|
def test_limiting_reader(self):
|
||||||
BYTES = 1024
|
BYTES = 1024
|
||||||
bytes_read = 0
|
bytes_read = 0
|
||||||
data = StringIO("*" * BYTES)
|
data = six.StringIO("*" * BYTES)
|
||||||
for chunk in sizelimit.LimitingReader(data, BYTES):
|
for chunk in sizelimit.LimitingReader(data, BYTES):
|
||||||
bytes_read += len(chunk)
|
bytes_read += len(chunk)
|
||||||
|
|
||||||
self.assertEquals(bytes_read, BYTES)
|
self.assertEquals(bytes_read, BYTES)
|
||||||
|
|
||||||
bytes_read = 0
|
bytes_read = 0
|
||||||
data = StringIO("*" * BYTES)
|
data = six.StringIO("*" * BYTES)
|
||||||
reader = sizelimit.LimitingReader(data, BYTES)
|
reader = sizelimit.LimitingReader(data, BYTES)
|
||||||
byte = reader.read(1)
|
byte = reader.read(1)
|
||||||
while len(byte) != 0:
|
while len(byte) != 0:
|
||||||
|
@ -49,7 +49,7 @@ class TestLimitingReader(utils.BaseTestCase):
|
||||||
|
|
||||||
def _consume_all_iter():
|
def _consume_all_iter():
|
||||||
bytes_read = 0
|
bytes_read = 0
|
||||||
data = StringIO("*" * BYTES)
|
data = six.StringIO("*" * BYTES)
|
||||||
for chunk in sizelimit.LimitingReader(data, BYTES - 1):
|
for chunk in sizelimit.LimitingReader(data, BYTES - 1):
|
||||||
bytes_read += len(chunk)
|
bytes_read += len(chunk)
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ class TestLimitingReader(utils.BaseTestCase):
|
||||||
|
|
||||||
def _consume_all_read():
|
def _consume_all_read():
|
||||||
bytes_read = 0
|
bytes_read = 0
|
||||||
data = StringIO("*" * BYTES)
|
data = six.StringIO("*" * BYTES)
|
||||||
reader = sizelimit.LimitingReader(data, BYTES - 1)
|
reader = sizelimit.LimitingReader(data, BYTES - 1)
|
||||||
byte = reader.read(1)
|
byte = reader.read(1)
|
||||||
while len(byte) != 0:
|
while len(byte) != 0:
|
||||||
|
|
|
@ -27,7 +27,7 @@ import eventlet
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
from openstack.common import exception
|
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 common as rpc_common
|
||||||
from openstack.common.rpc import dispatcher as rpc_dispatcher
|
from openstack.common.rpc import dispatcher as rpc_dispatcher
|
||||||
from tests import utils as test_utils
|
from tests import utils as test_utils
|
||||||
|
|
|
@ -29,7 +29,7 @@ import socket
|
||||||
import fixtures
|
import fixtures
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
from openstack.common.gettextutils import _
|
from openstack.common.gettextutils import _ # noqa
|
||||||
from tests.unit.rpc import common
|
from tests.unit.rpc import common
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -19,7 +19,7 @@ import datetime
|
||||||
import xmlrpclib
|
import xmlrpclib
|
||||||
|
|
||||||
import netaddr
|
import netaddr
|
||||||
from six import StringIO
|
import six
|
||||||
|
|
||||||
from openstack.common import jsonutils
|
from openstack.common import jsonutils
|
||||||
from tests import utils
|
from tests import utils
|
||||||
|
@ -34,7 +34,7 @@ class JSONUtilsTestCase(utils.BaseTestCase):
|
||||||
self.assertEqual(jsonutils.loads('{"a": "b"}'), {'a': 'b'})
|
self.assertEqual(jsonutils.loads('{"a": "b"}'), {'a': 'b'})
|
||||||
|
|
||||||
def test_load(self):
|
def test_load(self):
|
||||||
x = StringIO('{"a": "b"}')
|
x = six.StringIO('{"a": "b"}')
|
||||||
self.assertEqual(jsonutils.load(x), {'a': 'b'})
|
self.assertEqual(jsonutils.load(x), {'a': 'b'})
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,12 +21,12 @@ import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
from six import StringIO
|
import six
|
||||||
|
|
||||||
from openstack.common import context
|
from openstack.common import context
|
||||||
from openstack.common import jsonutils
|
from openstack.common import jsonutils
|
||||||
from openstack.common import log
|
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 openstack.common.notifier import api as notifier
|
||||||
from tests import utils as test_utils
|
from tests import utils as test_utils
|
||||||
|
|
||||||
|
@ -131,7 +131,8 @@ class PublishErrorsHandlerTestCase(test_utils.BaseTestCase):
|
||||||
"""Tests for log.PublishErrorsHandler"""
|
"""Tests for log.PublishErrorsHandler"""
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(PublishErrorsHandlerTestCase, self).setUp()
|
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):
|
def test_emit_cfg_log_notifier_in_notifier_drivers(self):
|
||||||
self.config(notification_driver=[
|
self.config(notification_driver=[
|
||||||
|
@ -367,7 +368,7 @@ class SetDefaultsTestCase(test_utils.BaseTestCase):
|
||||||
class LogConfigOptsTestCase(test_utils.BaseTestCase):
|
class LogConfigOptsTestCase(test_utils.BaseTestCase):
|
||||||
|
|
||||||
def test_print_help(self):
|
def test_print_help(self):
|
||||||
f = StringIO()
|
f = six.StringIO()
|
||||||
CONF([])
|
CONF([])
|
||||||
CONF.print_help(file=f)
|
CONF.print_help(file=f)
|
||||||
self.assertTrue('debug' in f.getvalue())
|
self.assertTrue('debug' in f.getvalue())
|
||||||
|
|
|
@ -23,7 +23,7 @@ import urllib2
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
from six import StringIO
|
import six
|
||||||
|
|
||||||
from openstack.common import jsonutils
|
from openstack.common import jsonutils
|
||||||
from openstack.common import policy
|
from openstack.common import policy
|
||||||
|
@ -779,7 +779,7 @@ class HttpCheckTestCase(PolicyBaseTestCase):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@mock.patch.object(urllib2, 'urlopen',
|
@mock.patch.object(urllib2, 'urlopen',
|
||||||
return_value=StringIO('True'))
|
return_value=six.StringIO('True'))
|
||||||
def test_accept(self, mock_urlopen):
|
def test_accept(self, mock_urlopen):
|
||||||
check = policy.HttpCheck('http', '//example.com/%(name)s')
|
check = policy.HttpCheck('http', '//example.com/%(name)s')
|
||||||
|
|
||||||
|
@ -798,7 +798,7 @@ class HttpCheckTestCase(PolicyBaseTestCase):
|
||||||
))
|
))
|
||||||
|
|
||||||
@mock.patch.object(urllib2, 'urlopen',
|
@mock.patch.object(urllib2, 'urlopen',
|
||||||
return_value=StringIO('other'))
|
return_value=six.StringIO('other'))
|
||||||
def test_reject(self, mock_urlopen):
|
def test_reject(self, mock_urlopen):
|
||||||
check = policy.HttpCheck('http', '//example.com/%(name)s')
|
check = policy.HttpCheck('http', '//example.com/%(name)s')
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ import fixtures
|
||||||
import os
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
from six import StringIO
|
import six
|
||||||
|
|
||||||
from openstack.common import processutils
|
from openstack.common import processutils
|
||||||
from tests import utils
|
from tests import utils
|
||||||
|
@ -214,7 +214,7 @@ class FakeSshChannel(object):
|
||||||
return self.rc
|
return self.rc
|
||||||
|
|
||||||
|
|
||||||
class FakeSshStream(StringIO):
|
class FakeSshStream(six.StringIO):
|
||||||
def setup_channel(self, rc):
|
def setup_channel(self, rc):
|
||||||
self.channel = FakeSshChannel(rc)
|
self.channel = FakeSshChannel(rc)
|
||||||
|
|
||||||
|
@ -226,9 +226,9 @@ class FakeSshConnection(object):
|
||||||
def exec_command(self, cmd):
|
def exec_command(self, cmd):
|
||||||
stdout = FakeSshStream('stdout')
|
stdout = FakeSshStream('stdout')
|
||||||
stdout.setup_channel(self.rc)
|
stdout.setup_channel(self.rc)
|
||||||
return (StringIO(),
|
return (six.StringIO(),
|
||||||
stdout,
|
stdout,
|
||||||
StringIO('stderr'))
|
six.StringIO('stderr'))
|
||||||
|
|
||||||
|
|
||||||
class SshExecuteTestCase(utils.BaseTestCase):
|
class SshExecuteTestCase(utils.BaseTestCase):
|
||||||
|
|
Loading…
Reference in New Issue