Remove six usage

Remove six, the python 2/3 compatibility library. It's not needed
anymore since the repo is python3 only.

Remove a now unneeded hacking test.

Change-Id: I40522c4accb4aaf8115d11fee8b081e2d991cb4d
This commit is contained in:
Andreas Jaeger 2020-05-11 10:17:47 +02:00
parent c1768401f7
commit e44c988306
42 changed files with 102 additions and 161 deletions

View File

@ -26,7 +26,6 @@ import collections
import uuid
from oslo_config import cfg
import six
from oslo_messaging._drivers import common as rpc_common
@ -62,7 +61,7 @@ def unpack_context(msg):
"""Unpack context from msg."""
context_dict = {}
for key in list(msg.keys()):
key = six.text_type(key)
key = str(key)
if key.startswith('_context_'):
value = msg.pop(key)
context_dict[key[9:]] = value

View File

@ -29,6 +29,7 @@ import collections
import logging
import os
import platform
import queue
import random
import sys
import threading
@ -38,9 +39,6 @@ import uuid
from oslo_utils import eventletutils
import proton
import pyngus
from six import iteritems
from six import itervalues
from six import moves
from oslo_messaging._drivers.amqp1_driver.addressing import AddresserFactory
from oslo_messaging._drivers.amqp1_driver.addressing import keyify
@ -868,7 +866,7 @@ class Controller(pyngus.ConnectionEventHandler):
self._command = os.path.basename(sys.argv[0])
self._pid = os.getpid()
# queue of drivertask objects to execute on the eventloop thread
self._tasks = moves.queue.Queue(maxsize=500)
self._tasks = queue.Queue(maxsize=500)
# limit the number of Task()'s to execute per call to _process_tasks().
# This allows the eventloop main thread to return to servicing socket
# I/O in a timely manner
@ -961,7 +959,7 @@ class Controller(pyngus.ConnectionEventHandler):
LOG.debug("Waiting for eventloop to exit")
self.processor.join(timeout)
self._hard_reset("Shutting down")
for sender in itervalues(self._all_senders):
for sender in self._all_senders.values():
sender.destroy()
self._all_senders.clear()
self._servers.clear()
@ -1134,7 +1132,7 @@ class Controller(pyngus.ConnectionEventHandler):
'vhost': ("/" + self.hosts.virtual_host
if self.hosts.virtual_host else "")})
for sender in itervalues(self._all_senders):
for sender in self._all_senders.values():
sender.attach(self._socket_connection.pyngus_conn,
self.reply_link, self.addresser)
@ -1181,8 +1179,8 @@ class Controller(pyngus.ConnectionEventHandler):
self.addresser = self.addresser_factory(props,
self.hosts.virtual_host
if self.pseudo_vhost else None)
for servers in itervalues(self._servers):
for server in itervalues(servers):
for servers in self._servers.values():
for server in servers.values():
server.attach(self._socket_connection.pyngus_conn,
self.addresser)
self.reply_link = Replies(self._socket_connection.pyngus_conn,
@ -1279,7 +1277,7 @@ class Controller(pyngus.ConnectionEventHandler):
del self._purged_senders[:]
self._active_senders.clear()
unused = []
for key, sender in iteritems(self._all_senders):
for key, sender in self._all_senders.items():
# clean up any sender links that no longer have messages to send
if sender.pending_messages == 0:
unused.append(key)
@ -1289,8 +1287,8 @@ class Controller(pyngus.ConnectionEventHandler):
for key in unused:
self._all_senders[key].destroy(reason)
del self._all_senders[key]
for servers in itervalues(self._servers):
for server in itervalues(servers):
for servers in self._servers.values():
for server in servers.values():
server.reset()
if self.reply_link:
self.reply_link.destroy()
@ -1300,13 +1298,13 @@ class Controller(pyngus.ConnectionEventHandler):
def _detach_senders(self):
"""Close all sender links"""
for sender in itervalues(self._all_senders):
for sender in self._all_senders.values():
sender.detach()
def _detach_servers(self):
"""Close all listener links"""
for servers in itervalues(self._servers):
for server in itervalues(servers):
for servers in self._servers.values():
for server in servers.values():
server.detach()
def _purge_sender_links(self):

View File

@ -14,6 +14,7 @@
# under the License.
import logging
import queue
import threading
import time
import uuid
@ -21,7 +22,6 @@ import uuid
import cachetools
from oslo_utils import eventletutils
from oslo_utils import timeutils
from six import moves
import oslo_messaging
from oslo_messaging._drivers import amqp as rpc_amqp
@ -48,7 +48,7 @@ class MessageOperationsHandler(object):
def __init__(self, name):
self.name = "%s (%s)" % (name, hex(id(self)))
self._tasks = moves.queue.Queue()
self._tasks = queue.Queue()
self._shutdown = eventletutils.Event()
self._shutdown_thread = threading.Thread(
@ -75,7 +75,7 @@ class MessageOperationsHandler(object):
while True:
try:
task = self._tasks.get(block=False)
except moves.queue.Empty:
except queue.Empty:
break
task()
@ -403,7 +403,7 @@ class ReplyWaiters(object):
def get(self, msg_id, timeout):
try:
return self._queues[msg_id].get(block=True, timeout=timeout)
except moves.queue.Empty:
except queue.Empty:
raise oslo_messaging.MessagingTimeout(
'Timed out waiting for a reply '
'to message ID %s' % msg_id)
@ -418,7 +418,7 @@ class ReplyWaiters(object):
queue.put(message_data)
def add(self, msg_id):
self._queues[msg_id] = moves.queue.Queue()
self._queues[msg_id] = queue.Queue()
queues_length = len(self._queues)
if queues_length > self._wrn_threshold:
LOG.warning('Number of call queues is %(queues_length)s, '
@ -529,7 +529,7 @@ class ReplyWaiter(object):
timeout = cm_timeout
try:
message = self.waiters.get(msg_id, timeout=timeout)
except moves.queue.Empty:
except queue.Empty:
self._raise_timeout_exception(msg_id)
reply, ending = self._process_reply(message)

View File

@ -18,7 +18,6 @@ import threading
from oslo_config import cfg
from oslo_utils import excutils
from oslo_utils import timeutils
import six
from oslo_messaging import exceptions
@ -65,8 +64,7 @@ class TransportDriverError(exceptions.MessagingException):
"""Base class for transport driver specific exceptions."""
@six.add_metaclass(abc.ABCMeta)
class IncomingMessage(object):
class IncomingMessage(object, metaclass=abc.ABCMeta):
"""The IncomingMessage class represents a single message received from the
messaging backend. Instances of this class are passed to up a server's
messaging processing logic. The backend driver must provide a concrete
@ -116,8 +114,7 @@ class IncomingMessage(object):
"""
@six.add_metaclass(abc.ABCMeta)
class RpcIncomingMessage(IncomingMessage):
class RpcIncomingMessage(IncomingMessage, metaclass=abc.ABCMeta):
"""The RpcIncomingMessage represents an RPC request message received from
the backend. This class must be used for RPC calls that return a value to
the caller.
@ -170,8 +167,7 @@ class RpcIncomingMessage(IncomingMessage):
"""
@six.add_metaclass(abc.ABCMeta)
class PollStyleListener(object):
class PollStyleListener(object, metaclass=abc.ABCMeta):
"""A PollStyleListener is used to transfer received messages to a server
for processing. A polling pattern is used to retrieve messages. A
PollStyleListener uses a separate thread to run the polling loop. A
@ -227,8 +223,7 @@ class PollStyleListener(object):
pass
@six.add_metaclass(abc.ABCMeta)
class Listener(object):
class Listener(object, metaclass=abc.ABCMeta):
"""A Listener is used to transfer incoming messages from the driver to a
server for processing. A callback is used by the driver to transfer the
messages.
@ -328,8 +323,7 @@ class PollStyleListenerAdapter(Listener):
self._poll_style_listener.cleanup()
@six.add_metaclass(abc.ABCMeta)
class BaseDriver(object):
class BaseDriver(object, metaclass=abc.ABCMeta):
"""Defines the backend driver interface. Each backend driver implementation
must provide a concrete derivation of this class implementing the backend
specific logic for its public methods.

View File

@ -15,13 +15,7 @@
# License for the specific language governing permissions and limitations
# under the License.
# TODO(smcginnis) update this once six has support for collections.abc
# (https://github.com/benjaminp/six/pull/241) or clean up once we drop py2.7.
try:
from collections.abc import Mapping
except ImportError:
from collections import Mapping
from collections.abc import Mapping
import copy
import logging
import sys
@ -29,14 +23,13 @@ import traceback
from oslo_serialization import jsonutils
from oslo_utils import timeutils
import six
import oslo_messaging
from oslo_messaging import _utils as utils
LOG = logging.getLogger(__name__)
_EXCEPTIONS_MODULE = 'exceptions' if six.PY2 else 'builtins'
_EXCEPTIONS_MODULE = 'builtins'
_EXCEPTIONS_MODULES = ['exceptions', 'builtins']
@ -184,8 +177,8 @@ def serialize_remote_exception(failure_info):
# NOTE(matiu): With cells, it's possible to re-raise remote, remote
# exceptions. Lets turn it back into the original exception type.
cls_name = six.text_type(failure.__class__.__name__)
mod_name = six.text_type(failure.__class__.__module__)
cls_name = str(failure.__class__.__name__)
mod_name = str(failure.__class__.__module__)
if (cls_name.endswith(_REMOTE_POSTFIX) and
mod_name.endswith(_REMOTE_POSTFIX)):
cls_name = cls_name[:-len(_REMOTE_POSTFIX)]
@ -194,7 +187,7 @@ def serialize_remote_exception(failure_info):
data = {
'class': cls_name,
'module': mod_name,
'message': six.text_type(failure),
'message': str(failure),
'tb': tb,
'args': failure.args,
'kwargs': kwargs
@ -206,7 +199,7 @@ def serialize_remote_exception(failure_info):
def deserialize_remote_exception(data, allowed_remote_exmods):
failure = jsonutils.loads(six.text_type(data))
failure = jsonutils.loads(str(data))
trace = failure.get('tb', [])
message = failure.get('message', "") + "\n" + "\n".join(trace)
@ -235,7 +228,7 @@ def deserialize_remote_exception(data, allowed_remote_exmods):
failure = klass(*failure.get('args', []), **failure.get('kwargs', {}))
except (AttributeError, TypeError, ImportError) as error:
LOG.warning("Failed to rebuild remote exception due to error: %s",
six.text_type(error))
str(error))
return oslo_messaging.RemoteError(name, failure.get('message'), trace)
ex_type = type(failure)

View File

@ -14,12 +14,12 @@
# under the License.
import copy
import queue
import threading
import time
from oslo_serialization import jsonutils
from oslo_utils import eventletutils
from six import moves
import oslo_messaging
from oslo_messaging._drivers import base
@ -133,8 +133,8 @@ class FakeExchange(object):
self.deliver_message(topic, ctxt, message, server=server,
fanout=fanout, reply_q=reply_q)
for queue in queues:
queue.append((ctxt, message, reply_q, requeue))
for q in queues:
q.append((ctxt, message, reply_q, requeue))
def poll(self, target, pool):
with self._queues_lock:
@ -195,7 +195,7 @@ class FakeDriver(base.BaseDriver):
reply_q = None
if wait_for_reply:
reply_q = moves.queue.Queue()
reply_q = queue.Queue()
exchange.deliver_message(target.topic, ctxt, message,
server=target.server,
@ -209,7 +209,7 @@ class FakeDriver(base.BaseDriver):
raise failure
else:
return reply
except moves.queue.Empty:
except queue.Empty:
raise oslo_messaging.MessagingTimeout(
'No reply on topic %s' % target.topic)

View File

@ -24,6 +24,7 @@ import ssl
import sys
import threading
import time
from urllib import parse
import uuid
import kombu
@ -34,9 +35,6 @@ from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import eventletutils
from oslo_utils import importutils
import six
import six.moves
from six.moves.urllib import parse
import oslo_messaging
from oslo_messaging._drivers import amqp as rpc_amqp
@ -320,7 +318,7 @@ class Consumer(object):
self.declare(conn)
try:
self.queue.consume(callback=self._callback,
consumer_tag=six.text_type(tag),
consumer_tag=str(tag),
nowait=self.nowait)
except conn.connection.channel_errors as exc:
# We retries once because of some races that we can
@ -340,14 +338,14 @@ class Consumer(object):
exc.method_name == 'Basic.ack'):
self.declare(conn)
self.queue.consume(callback=self._callback,
consumer_tag=six.text_type(tag),
consumer_tag=str(tag),
nowait=self.nowait)
else:
raise
def cancel(self, tag):
LOG.trace('ConsumerBase.cancel: canceling %s', tag)
self.queue.cancel(six.text_type(tag))
self.queue.cancel(str(tag))
def _callback(self, message):
"""Call callback with deserialized message.
@ -753,7 +751,7 @@ class Connection(object):
info = {'err_str': exc, 'sleep_time': interval}
info.update(self._get_connection_info(conn_error=True))
if 'Socket closed' in six.text_type(exc):
if 'Socket closed' in str(exc):
LOG.error('[%(connection_id)s] AMQP server'
' %(hostname)s:%(port)s closed'
' the connection. Check login credentials:'
@ -867,8 +865,8 @@ class Connection(object):
"""Close/release this connection."""
self._heartbeat_stop()
if self.connection:
for consumer in six.moves.filter(lambda c: c.type == 'fanout',
self._consumers):
for consumer in filter(lambda c: c.type == 'fanout',
self._consumers):
LOG.debug('[connection close] Deleting fanout '
'queue: %s ' % consumer.queue.name)
consumer.queue.delete()

View File

@ -19,7 +19,6 @@ import threading
from oslo_log import log as logging
from oslo_utils import timeutils
import six
from oslo_messaging._drivers import common
@ -36,8 +35,7 @@ else:
cond.wait()
@six.add_metaclass(abc.ABCMeta)
class Pool(object):
class Pool(object, metaclass=abc.ABCMeta):
"""A thread-safe object pool.
Modelled after the eventlet.pools.Pool interface, but designed to be safe

View File

@ -13,16 +13,13 @@
import abc
import six
__all__ = [
"DispatcherBase"
]
@six.add_metaclass(abc.ABCMeta)
class DispatcherBase(object):
class DispatcherBase(object, metaclass=abc.ABCMeta):
"Base class for dispatcher"
@abc.abstractmethod

View File

@ -13,8 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
import six
__all__ = ['MessagingException', 'MessagingTimeout', 'MessageDeliveryFailure',
'InvalidTarget', 'MessageUndeliverable']
@ -35,7 +33,7 @@ class InvalidTarget(MessagingException, ValueError):
"""Raised if a target does not meet certain pre-conditions."""
def __init__(self, msg, target):
msg = msg + ":" + six.text_type(target)
msg = msg + ":" + str(target)
super(InvalidTarget, self).__init__(msg)
self.target = target

View File

@ -16,7 +16,6 @@ import re
import ast
from hacking import core
import six
oslo_namespace_imports_dot = re.compile(r"import[\s]+oslo[.][^\s]+")
@ -45,18 +44,6 @@ def check_oslo_namespace_imports(logical_line):
yield(0, msg)
@core.flake8ext
def check_mock_imports(logical_line):
if re.match(mock_imports_directly, logical_line):
msg = ("O322: '%s' must be used instead of '%s'.") % (
logical_line.replace('import mock', 'from six.moves import mock'),
logical_line)
yield(0, msg)
elif re.match(mock_imports_direclty_from, logical_line):
msg = "O322: Use mock from six.moves."
yield(0, msg)
class BaseASTChecker(ast.NodeVisitor):
"""Provides a simple framework for writing AST-based checks.
@ -152,7 +139,7 @@ class CheckForLoggingIssues(BaseASTChecker):
if obj_name is None:
return None
return obj_name + '.' + method_name
elif isinstance(node, six.string_types):
elif isinstance(node, str):
return node
else: # could be Subscript, Call or many more
return None
@ -284,10 +271,7 @@ class CheckForLoggingIssues(BaseASTChecker):
peers = find_peers(node)
for peer in peers:
if isinstance(peer, ast.Raise):
if six.PY3:
exc = peer.exc
else:
exc = peer.type
exc = peer.exc
if (isinstance(exc, ast.Call) and
len(exc.args) > 0 and
isinstance(exc.args[0], ast.Name) and

View File

@ -18,8 +18,6 @@ import itertools
import logging
import operator
import six
from oslo_messaging import dispatcher
from oslo_messaging import serializer as msg_serializer
@ -124,7 +122,7 @@ class BatchNotificationDispatcher(NotificationDispatcher):
requeues = set()
for priority, messages in messages_grouped:
__, raw_messages, messages = six.moves.zip(*messages)
__, raw_messages, messages = zip(*messages)
if priority not in PRIORITIES:
LOG.warning('Unknown priority "%s"', priority)
continue

View File

@ -15,8 +15,6 @@
import re
import six
class NotificationFilter(object):
@ -63,7 +61,7 @@ class NotificationFilter(object):
def _check_for_single_mismatch(data, regex):
if regex is None:
return False
if not isinstance(data, six.string_types):
if not isinstance(data, str):
return True
if not regex.match(data):
return True

View File

@ -22,7 +22,6 @@ import uuid
from oslo_config import cfg
from oslo_utils import timeutils
import six
from stevedore import extension
from stevedore import named
@ -106,8 +105,7 @@ def _send_notification():
notifier._notify({}, args.event_type, args.payload, args.priority)
@six.add_metaclass(abc.ABCMeta)
class Driver(object):
class Driver(object, metaclass=abc.ABCMeta):
"""Base driver for Notifications"""
def __init__(self, conf, topics, transport):
@ -182,7 +180,7 @@ class Notifier(object):
Notification messages follow the following format::
{'message_id': six.text_type(uuid.uuid4()),
{'message_id': str(uuid.uuid4()),
'publisher_id': 'compute.host1',
'timestamp': timeutils.utcnow(),
'priority': 'WARN',
@ -300,12 +298,12 @@ class Notifier(object):
payload = self._serializer.serialize_entity(ctxt, payload)
ctxt = self._serializer.serialize_context(ctxt)
msg = dict(message_id=six.text_type(uuid.uuid4()),
msg = dict(message_id=str(uuid.uuid4()),
publisher_id=publisher_id or self.publisher_id,
event_type=event_type,
priority=priority,
payload=payload,
timestamp=six.text_type(timeutils.utcnow()))
timestamp=str(timeutils.utcnow()))
def do_notify(ext):
try:

View File

@ -19,7 +19,6 @@ import abc
import logging
from oslo_config import cfg
import six
from oslo_messaging._drivers import base as driver_base
from oslo_messaging import _utils as utils
@ -85,8 +84,7 @@ class ClientSendError(exceptions.MessagingException):
self.ex = ex
@six.add_metaclass(abc.ABCMeta)
class _BaseCallContext(object):
class _BaseCallContext(object, metaclass=abc.ABCMeta):
_marker = object()

View File

@ -22,8 +22,6 @@ import logging
import sys
import threading
import six
from oslo_utils import eventletutils
from oslo_messaging import _utils as utils
@ -83,8 +81,7 @@ class UnsupportedVersion(RPCDispatcherError):
self.method = method
@six.add_metaclass(ABCMeta)
class RPCAccessPolicyBase(object):
class RPCAccessPolicyBase(object, metaclass=ABCMeta):
"""Determines which endpoint methods may be invoked via RPC"""
@abstractmethod

View File

@ -17,13 +17,11 @@
import abc
from oslo_serialization import jsonutils
import six
__all__ = ['Serializer', 'NoOpSerializer', 'JsonPayloadSerializer']
@six.add_metaclass(abc.ABCMeta)
class Serializer(object):
class Serializer(object, metaclass=abc.ABCMeta):
"""Generic (de-)serialization definition base class."""
@abc.abstractmethod

View File

@ -27,7 +27,6 @@ from oslo_config import cfg
from oslo_service import service
from oslo_utils import eventletutils
from oslo_utils import timeutils
import six
from stevedore import driver
from oslo_messaging._drivers import base as driver_base
@ -297,8 +296,8 @@ def ordered(after=None, reset_after=None):
return _ordered
@six.add_metaclass(abc.ABCMeta)
class MessageHandlingServer(service.ServiceBase, _OrderedTaskRunner):
class MessageHandlingServer(service.ServiceBase, _OrderedTaskRunner,
metaclass=abc.ABCMeta):
"""Server for handling messages.
Connect a transport to a dispatcher that knows how to process the

View File

@ -19,5 +19,5 @@ eventlet.monkey_patch()
# oslotest prepares mock for six in oslotest/__init__.py as follow:
# six.add_move(six.MovedModule('mock', 'mock', 'unittest.mock')) and
# oslo.messaging imports oslotest before importing test submodules to
# setup six.moves for mock, then "from six.moves import mock" works well.
# setup six.moves for mock, then "from unittest import mock" works well.
import oslotest

View File

@ -15,21 +15,21 @@
import copy
import logging
import os
import queue
import select
import shlex
import shutil
from six.moves import mock
import socket
import subprocess
import sys
import tempfile
import threading
import time
from unittest import mock
import uuid
from oslo_utils import eventletutils
from oslo_utils import importutils
from six import moves
from string import Template
import testtools
@ -74,7 +74,7 @@ class _ListenerThread(threading.Thread):
self.listener = listener
self.msg_count = msg_count
self._msg_ack = msg_ack
self.messages = moves.queue.Queue()
self.messages = queue.Queue()
self.daemon = True
self.started = eventletutils.Event()
self._done = eventletutils.Event()
@ -106,7 +106,7 @@ class _ListenerThread(threading.Thread):
while True:
m = self.messages.get(False)
msgs.append(m)
except moves.queue.Empty:
except queue.Empty:
pass
return msgs

View File

@ -11,8 +11,9 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from six.moves import mock
import testscenarios
from unittest import mock
import oslo_messaging
from oslo_messaging._drivers import impl_kafka as kafka_driver

View File

@ -32,7 +32,7 @@ from oslo_messaging._drivers import common as driver_common
from oslo_messaging._drivers import impl_rabbit as rabbit_driver
from oslo_messaging.exceptions import MessageDeliveryFailure
from oslo_messaging.tests import utils as test_utils
from six.moves import mock
from unittest import mock
load_tests = testscenarios.load_tests_apply_scenarios

View File

@ -17,7 +17,6 @@ import uuid
import concurrent.futures
from oslo_config import cfg
import six.moves
from testtools import matchers
import oslo_messaging
@ -535,7 +534,7 @@ class NotifyTestCase(utils.SkipIfNoTransportURL):
batch_timeout=batch_timeout))
notifier = listener.notifier('abc')
for i in six.moves.range(0, 205):
for i in range(0, 205):
notifier.info({}, 'test%s' % i, 'Hello World!')
events = listener.get_events(timeout=get_timeout)
self.assertEqual(3, len(events))

View File

@ -12,12 +12,12 @@
# under the License.
import os
import queue
import time
import uuid
import fixtures
from oslo_config import cfg
from six import moves
import oslo_messaging
from oslo_messaging._drivers.kafka_driver import kafka_options
@ -102,7 +102,7 @@ class RpcServerFixture(fixtures.Fixture):
self.target = target
self.endpoint = endpoint or TestServerEndpoint()
self.executor = executor
self.syncq = moves.queue.Queue()
self.syncq = queue.Queue()
self.ctrl_target = ctrl_target or self.target
def setUp(self):
@ -323,7 +323,7 @@ class NotificationFixture(fixtures.Fixture):
self.conf = conf
self.url = url
self.topics = topics
self.events = moves.queue.Queue()
self.events = queue.Queue()
self.name = str(id(self))
self.batch = batch
@ -395,7 +395,7 @@ class NotificationFixture(fixtures.Fixture):
try:
while True:
results.append(self.events.get(timeout=timeout))
except moves.queue.Empty:
except queue.Empty:
pass
return results

View File

@ -19,7 +19,7 @@ import testscenarios
import oslo_messaging
from oslo_messaging.notify import dispatcher as notify_dispatcher
from oslo_messaging.tests import utils as test_utils
from six.moves import mock
from unittest import mock
load_tests = testscenarios.load_tests_apply_scenarios

View File

@ -23,7 +23,7 @@ import oslo_messaging
from oslo_messaging.notify import dispatcher
from oslo_messaging.notify import notifier as msg_notifier
from oslo_messaging.tests import utils as test_utils
from six.moves import mock
from unittest import mock
load_tests = testscenarios.load_tests_apply_scenarios

View File

@ -17,7 +17,7 @@ import fixtures
import oslo_messaging
from oslo_messaging.notify import log_handler
from oslo_messaging.tests import utils as test_utils
from six.moves import mock
from unittest import mock
class PublishErrorsHandlerTestCase(test_utils.BaseTestCase):

View File

@ -23,7 +23,7 @@ import testscenarios
import oslo_messaging
from oslo_messaging.tests import utils as test_utils
from six.moves import mock
from unittest import mock
load_tests = testscenarios.load_tests_apply_scenarios

View File

@ -19,7 +19,7 @@ import webob
from oslo_messaging.notify import middleware
from oslo_messaging.tests import utils
from six.moves import mock
from unittest import mock
class FakeApp(object):

View File

@ -34,7 +34,7 @@ from oslo_messaging.notify import messaging
from oslo_messaging.notify import notifier as msg_notifier
from oslo_messaging import serializer as msg_serializer
from oslo_messaging.tests import utils as test_utils
from six.moves import mock
from unittest import mock
load_tests = testscenarios.load_tests_apply_scenarios

View File

@ -14,8 +14,8 @@
# under the License.
from oslo_config import cfg
from six.moves import mock
import testscenarios
from unittest import mock
import oslo_messaging
from oslo_messaging import exceptions

View File

@ -19,7 +19,7 @@ import oslo_messaging
from oslo_messaging import rpc
from oslo_messaging import serializer as msg_serializer
from oslo_messaging.tests import utils as test_utils
from six.moves import mock
from unittest import mock
load_tests = testscenarios.load_tests_apply_scenarios

View File

@ -14,12 +14,13 @@
# under the License.
import threading
from unittest import mock
import eventlet
import fixtures
from oslo_config import cfg
from oslo_utils import eventletutils
from six.moves import mock
import testscenarios
import oslo_messaging

View File

@ -16,7 +16,6 @@
import sys
from oslo_serialization import jsonutils
import six
import testscenarios
import oslo_messaging
@ -25,8 +24,8 @@ from oslo_messaging.tests import utils as test_utils
load_tests = testscenarios.load_tests_apply_scenarios
EXCEPTIONS_MODULE = 'exceptions' if six.PY2 else 'builtins'
OTHER_EXCEPTIONS_MODULE = 'builtins' if six.PY2 else 'exceptions'
EXCEPTIONS_MODULE = 'builtins'
OTHER_EXCEPTIONS_MODULE = 'exceptions'
class NovaStyleException(Exception):
@ -289,9 +288,9 @@ class DeserializeRemoteExceptionTestCase(test_utils.BaseTestCase):
self.assertIsInstance(ex, self.cls)
self.assertEqual(self.remote_name, ex.__class__.__name__)
self.assertEqual(self.str, six.text_type(ex))
self.assertEqual(self.str, str(ex))
if hasattr(self, 'msg'):
self.assertEqual(self.msg, six.text_type(ex))
self.assertEqual(self.msg, str(ex))
self.assertEqual((self.msg,) + self.remote_args, ex.args)
else:
self.assertEqual(self.remote_args, ex.args)

View File

@ -12,7 +12,9 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from six.moves import mock
from unittest import mock
import stevedore
import testtools

View File

@ -14,9 +14,9 @@
# under the License.
import fixtures
from unittest import mock
from oslo_config import cfg
import six
from six.moves import mock
from stevedore import driver
import testscenarios
@ -150,7 +150,7 @@ class GetTransportSadPathTestCase(test_utils.BaseTestCase):
ex_msg_contains = self.ex.pop('msg_contains')
ex = self.assertRaises(
ex_cls, oslo_messaging.get_transport, self.conf, url=self.url)
self.assertIn(ex_msg_contains, six.text_type(ex))
self.assertIn(ex_msg_contains, str(ex))
for k, v in self.ex.items():
self.assertTrue(hasattr(ex, k))
self.assertEqual(v, str(getattr(ex, k)))
@ -172,7 +172,7 @@ class _SetDefaultsFixture(fixtures.Fixture):
def first(seq, default=None, key=None):
if key is None:
key = bool
return next(six.moves.filter(key, seq), default)
return next(filter(key, seq), default)
def default(opts, name):
return first(opts, key=lambda o: o.name == name).default

View File

@ -16,7 +16,7 @@
from oslo_messaging._drivers import common
from oslo_messaging import _utils as utils
from oslo_messaging.tests import utils as test_utils
from six.moves import mock
from unittest import mock
class VersionIsCompatibleTestCase(test_utils.BaseTestCase):

View File

@ -21,9 +21,8 @@ import logging
from debtcollector import removals
from oslo_config import cfg
import six
from six.moves.urllib import parse
from stevedore import driver
from urllib import parse
from oslo_messaging import exceptions
@ -456,7 +455,7 @@ class TransportURL(object):
conf.register_opts(_transport_opts)
url = url or conf.transport_url
if not isinstance(url, six.string_types):
if not isinstance(url, str):
raise InvalidTransportURL(url, 'Wrong URL type')
url = parse.urlparse(url)

View File

@ -14,7 +14,6 @@ stevedore>=1.20.0 # Apache-2.0
debtcollector>=1.2.0 # Apache-2.0
# for jsonutils
six>=1.10.0 # MIT
cachetools>=2.0.0 # MIT License
WebOb>=1.7.1 # MIT

View File

@ -6,7 +6,6 @@
hacking>=3.0,<3.1.0 # Apache-2.0
fixtures>=3.0.0 # Apache-2.0/BSD
mock>=2.0.0 # BSD
stestr>=2.0.0 # Apache-2.0
testscenarios>=0.4 # Apache-2.0/BSD
testtools>=2.2.0 # MIT

View File

@ -23,7 +23,6 @@ import logging
import os
import random
import signal
import six
import socket
import string
import sys
@ -139,7 +138,7 @@ class MessageStatsCollector(object):
max_latency = 0
sum_latencies = 0
for i in six.moves.range(count):
for i in range(count):
p = self.buffer[i]
size += len(p.cargo)
@ -471,10 +470,10 @@ def generate_messages(messages_count):
messages_count = MESSAGES_LIMIT
LOG.info("Generating %d random messages", messages_count)
generator = init_random_generator()
for i in six.moves.range(messages_count):
for i in range(messages_count):
length = generator()
msg = ''.join(random.choice(
string.ascii_lowercase) for